Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of null (reading 'date') #476

Closed
3 tasks done
Velyks opened this issue Nov 19, 2024 · 13 comments · Fixed by #478
Closed
3 tasks done

Cannot read properties of null (reading 'date') #476

Velyks opened this issue Nov 19, 2024 · 13 comments · Fixed by #478
Labels

Comments

@Velyks
Copy link

Velyks commented Nov 19, 2024

Contributing guidelines

I've found a bug, and:

  • The documentation does not mention anything about my problem
  • There are no open or closed issues that are related to my problem

Description

Using the v5 tag has suddenly resulted in the error "Cannot read properties of null (reading 'date')" when no date is used. Pinning to v5.5.1 seems to fix it so this probably came in with v5.6.0.

This is running Github Enterprise v3.13.6

The run options used are shown below.

Run docker/metadata-action@v5
  with:
    images: 123456789012.dkr.ecr.eu-west-1.amazonaws.com/blah
    tags: # ci-<head-sha>
  type=raw,enable=true,value=ci-1234567890abcdefgh
  # ci-<merge-sha or commit on main>
  type=sha,format=long,prefix=ci-
  # pr-123; automatically only on PRs
  type=ref,event=pr,prefix=pr-
  
    context: workflow
    github-token: ***
  env:
    IMAGE_REPO: 123456789012.dkr.ecr.eu-west-1.amazonaws.com/blah

Expected behaviour

It does not error.

Actual behaviour

"Cannot read properties of null (reading 'date')" is returned and it exits with an error.

Repository URL

No response

Workflow run URL

No response

YAML workflow

name: Build, Tag, and Push CI Image
author: blah@mycompany
description: "Build an image and tag it appropriately for Company"

inputs:
  image-name:
    description: "The full image name, including any external repo."
    required: true
  dockerhub-username:
    description: "Username for Dockerhub"
    required: false
  dockerhub-password:
    description: "Password for Dockerhub"
    required: false
  aws-role-arn:
    description: "AWS role to assume to access ECR"
    required: false
  aws-ecr-endpoint:
    description: "The AWS endpoint to pull or push from."
    required: false
  dockerfile:
    description: "Path to the Dockerfile to use"
    default: "${{ github.workspace }}/Dockerfile"
    required: false
  export_image_locally:
    description: "Export the created image from Buildx to the local docker server for later use in the current job."
    default: "false"
    required: false
  tag-prefix:
    description: "Add a prefix to all image tags"
    required: false
  target:
    description: "The target of a multistage Dockerfile to build"
    required: false

outputs:
  ci-image:
    description: "The full CI image name and tag"
    value: ${{ steps.docker-metadata.outputs.json && fromJSON(steps.docker-metadata.outputs.json).tags[0] }}
  metadata:
    description: "The generated docker metatata"
    value: ${{ steps.docker-metadata.outputs.json }}

runs:
  using: "composite"
  steps:
    - name: Configure AWS credentials from Role
      if: inputs.aws-role-arn != ''
      uses: aws-actions/configure-aws-credentials@v4
      with:
        role-to-assume: ${{ inputs.aws-role-arn }}
        aws-region: eu-west-1
    - name: Docker Login Hub
      if: inputs.dockerhub-username != '' && inputs.dockerhub-password != ''
      uses: docker/login-action@v3
      with:
        username: ${{ inputs.dockerhub-username }}
        password: ${{ inputs.dockerhub-password }}
    - name: Docker Login ECR
      if: inputs.aws-role-arn != '' && inputs.aws-ecr-endpoint != ''
      uses: docker/login-action@v3
      with:
        registry: ${{ inputs.aws-ecr-endpoint }}
    - name: Compute Metadata
      id: docker-metadata
      uses: docker/metadata-action@v5
      with:
        images: ${{ inputs.image-name }}
        tags: |
          # ci-<head-sha>
          type=raw,enable=${{ github.event_name == 'pull_request' }},value=${{ inputs.tag-prefix }}ci-${{ github.event.pull_request.head.sha }}
          # ci-<merge-sha or commit on main>
          type=sha,format=long,prefix=${{ inputs.tag-prefix }}ci-
          # pr-123; automatically only on PRs
          type=ref,event=pr,prefix=${{ inputs.tag-prefix }}pr-
    - name: Setup Docker Buildx
      uses: docker/setup-buildx-action@v3
    - name: Make Cache Dir
      shell: sh
      run: |
        sudo mkdir -p /cache/buildx
        sudo chmod 777 /cache/buildx
    - name: Build and Push CI images
      uses: docker/build-push-action@v6
      env:
        # No summaries on GHES with at least v6.3.0
        # https://github.com/docker/build-push-action/issues/1154
        DOCKER_BUILD_SUMMARY: "false"
      with:
        context: "."
        target: ${{ inputs.target }}
        build-args: |
          GIT_SHA=${{ github.event.pull_request.head.sha || github.sha }}
        cache-from: |
          type=local,src=/cache/buildx
          type=registry,ref=${{ inputs.image-name }}:${{ inputs.tag-prefix }}pr-${{ github.event.number }}
          type=registry,ref=${{ inputs.image-name }}:latest
        cache-to: |
          type=local,mode=max,dest=/cache/buildx
          type=inline
        file: ${{ inputs.dockerfile }}
        load: ${{ inputs.export_image_locally != 'false' }}
        pull: true
        push: true
        tags: ${{ steps.docker-metadata.outputs.tags }}
name: build-test-deploy

on:
  pull_request:
    branches:
      - master
  push:
    branches:
      - master
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch }}

env:
  IMAGE_REPO: ${{ vars.AMAZON_ECR_ENDPOINT_ECS }}/blah

jobs:
  build:
    runs-on: x86-64
    steps:
      - name: Checkout codebase
        uses: actions/checkout@v4
      - name: Build
        id: build
        uses: company/build-and-tag@main
        with:
          image-name: ${{ env.IMAGE_REPO }}
    outputs:
      ci-image: ${{ steps.build.outputs.ci-image }}

Workflow logs

##[debug]Evaluating condition for step: 'Build'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Build
##[debug]Register post job cleanup for action: company/build-and-tag@main
##[debug]Loading inputs
##[debug]Evaluating: env.IMAGE_REPO
##[debug]Evaluating Index:
##[debug]..Evaluating env:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'IMAGE_REPO'
##[debug]=> '924697190257.dkr.ecr.eu-west-1.amazonaws.com/blah'
##[debug]Result: '924697190257.dkr.ecr.eu-west-1.amazonaws.com/blah'
##[debug]Evaluating: format('{0}/Dockerfile', github.workspace)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> '{0}/Dockerfile'
##[debug]..Evaluating Index:
##[debug]....Evaluating github:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'workspace'
##[debug]..=> '/home/runner/_work/blah/blah'
##[debug]=> '/home/runner/_work/blah/blah/Dockerfile'
##[debug]Result: '/home/runner/_work/blah/blah/Dockerfile'
##[debug]Loading env
Run company/build-and-tag@main
##[debug]Evaluating condition for step: 'run'
##[debug]Evaluating: (success() && (inputs.aws-role-arn != ''))
##[debug]Evaluating And:
##[debug]..Evaluating success:
##[debug]..=> true
##[debug]..Evaluating NotEqual:
##[debug]....Evaluating Index:
##[debug]......Evaluating inputs:
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'aws-role-arn'
##[debug]....=> ''
##[debug]....Evaluating String:
##[debug]....=> ''
##[debug]..=> false
##[debug]=> false
##[debug]Expanded: (true && ('' != ''))
##[debug]Result: false
##[debug]Evaluating condition for step: 'run'
##[debug]Evaluating: (success() && (inputs.dockerhub-username != '') && (inputs.dockerhub-password != ''))
##[debug]Evaluating And:
##[debug]..Evaluating success:
##[debug]..=> true
##[debug]..Evaluating NotEqual:
##[debug]....Evaluating Index:
##[debug]......Evaluating inputs:
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'dockerhub-username'
##[debug]....=> ''
##[debug]....Evaluating String:
##[debug]....=> ''
##[debug]..=> false
##[debug]=> false
##[debug]Expanded: (true && ('' != '') && (inputs['dockerhub-password'] != ''))
##[debug]Result: false
##[debug]Evaluating condition for step: 'run'
##[debug]Evaluating: (success() && (inputs.aws-role-arn != '') && (inputs.aws-ecr-endpoint != ''))
##[debug]Evaluating And:
##[debug]..Evaluating success:
##[debug]..=> true
##[debug]..Evaluating NotEqual:
##[debug]....Evaluating Index:
##[debug]......Evaluating inputs:
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'aws-role-arn'
##[debug]....=> ''
##[debug]....Evaluating String:
##[debug]....=> ''
##[debug]..=> false
##[debug]=> false
##[debug]Expanded: (true && ('' != '') && (inputs['aws-ecr-endpoint'] != ''))
##[debug]Result: false
##[debug]Evaluating condition for step: 'run'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: run
##[debug]Loading inputs
##[debug]Evaluating: inputs.image-name
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'image-name'
##[debug]=> '924697190257.dkr.ecr.eu-west-1.amazonaws.com/blah'
##[debug]Result: '924697190257.dkr.ecr.eu-west-1.amazonaws.com/blah'
##[debug]Evaluating: format('# ci-<head-sha>
##[debug]type=raw,enable={0},value={1}ci-{2}
##[debug]# ci-<merge-sha or commit on main>
##[debug]type=sha,format=long,prefix={3}ci-
##[debug]# pr-123; automatically only on PRs
##[debug]type=ref,event=pr,prefix={4}pr-
##[debug]', (github.event_name == 'pull_request'), inputs.tag-prefix, github.event.pull_request.head.sha, inputs.tag-prefix, inputs.tag-prefix)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> '# ci-<head-sha>
##[debug]type=raw,enable={0},value={1}ci-{2}
##[debug]# ci-<merge-sha or commit on main>
##[debug]type=sha,format=long,prefix={3}ci-
##[debug]# pr-123; automatically only on PRs
##[debug]type=ref,event=pr,prefix={4}pr-
##[debug]'
##[debug]..Evaluating Equal:
##[debug]....Evaluating Index:
##[debug]......Evaluating github:
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'event_name'
##[debug]....=> 'pull_request'
##[debug]....Evaluating String:
##[debug]....=> 'pull_request'
##[debug]..=> true
##[debug]..Evaluating Index:
##[debug]....Evaluating inputs:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'tag-prefix'
##[debug]..=> ''
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating Index:
##[debug]..........Evaluating github:
##[debug]..........=> Object
##[debug]..........Evaluating String:
##[debug]..........=> 'event'
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'pull_request'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'head'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'sha'
##[debug]..=> '120bde3c55876f8f0605c8d75e5a8fd31b642047'
##[debug]..Evaluating Index:
##[debug]....Evaluating inputs:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'tag-prefix'
##[debug]..=> ''
##[debug]..Evaluating Index:
##[debug]....Evaluating inputs:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'tag-prefix'
##[debug]..=> ''
##[debug]=> '# ci-<head-sha>
##[debug]type=raw,enable=true,value=ci-120bde3c55876f8f0605c8d75e5a8fd31b642047
##[debug]# ci-<merge-sha or commit on main>
##[debug]type=sha,format=long,prefix=ci-
##[debug]# pr-123; automatically only on PRs
##[debug]type=ref,event=pr,prefix=pr-
##[debug]'
##[debug]Result: '# ci-<head-sha>
##[debug]type=raw,enable=true,value=ci-120bde3c55876f8f0605c8d75e5a8fd31b642047
##[debug]# ci-<merge-sha or commit on main>
##[debug]type=sha,format=long,prefix=ci-
##[debug]# pr-123; automatically only on PRs
##[debug]type=ref,event=pr,prefix=pr-
##[debug]'
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run docker/metadata-action@v5
  with:
    images: 924697190257.dkr.ecr.eu-west-1.amazonaws.com/blah
    tags: # ci-<head-sha>
  type=raw,enable=true,value=ci-120bde3c55876f8f0605c8d75e5a8fd31b642047
  # ci-<merge-sha or commit on main>
  type=sha,format=long,prefix=ci-
  # pr-123; automatically only on PRs
  type=ref,event=pr,prefix=pr-
  
    context: workflow
    github-token: ***
  env:
    IMAGE_REPO: 924697190257.dkr.ecr.eu-west-1.amazonaws.com/blah
  
Error: Cannot read properties of null (reading 'date')
##[debug]Node Action run completed with exit code 1
##[debug]Save intra-action state isPost = true
##[debug]Finished: run
##[debug]Evaluating condition for step: 'run'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> false
##[debug]Result: false
##[debug]Evaluating condition for step: 'run'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> false
##[debug]Result: false
##[debug]Evaluating condition for step: 'run'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> false
##[debug]Result: false
##[debug]Evaluating: (steps.docker-metadata.outputs.json && fromJSON(steps.docker-metadata.outputs.json).tags[0])
##[debug]Evaluating And:
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating steps:
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'docker-metadata'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'outputs'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'json'
##[debug]..=> null
##[debug]=> null
##[debug]Expanded: (null && fromJSON(steps['docker-metadata']['outputs']['json'])['tags'][0])
##[debug]Result: null
##[debug]Evaluating: steps.docker-metadata.outputs.json
##[debug]Evaluating Index:
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating steps:
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'docker-metadata'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'outputs'
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'json'
##[debug]=> null
##[debug]Result: null
##[debug]Finishing: Build

BuildKit logs


Additional info

No response

@crazy-max
Copy link
Member

crazy-max commented Nov 19, 2024

Thanks for your report, seems related to #471 (cc @trim21)

@Velyks Can you post full workflow logs please or at least the logs of the metadata action step?

@trim21
Copy link
Contributor

trim21 commented Nov 19, 2024

can you provide a public reproduction repo?

@crazy-max
Copy link
Member

@trim21 I guess this relates to what I checked in #475 (comment) where committer can be null.

@Velyks
Copy link
Author

Velyks commented Nov 19, 2024

@Velyks Can you post full workflow logs please or at least the logs of the metadata action step?

Done

can you provide a public reproduction repo?

Might take me a while but I'll try.

@trim21
Copy link
Contributor

trim21 commented Nov 19, 2024

did you trigger this in a PR?

@Velyks
Copy link
Author

Velyks commented Nov 19, 2024

did you trigger this in a PR?

Yes, from a branch in the same repo. I've added the relevant sections of the workflow file to the issue underneath our in-house action.

@trim21
Copy link
Contributor

trim21 commented Nov 19, 2024

would you mind try docker/metadata-action@e2f1776f12f30b5ac969ca7a00d71db4e60ae80e with debug log level and paste output here?

Image

@crazy-max
Copy link
Member

@Velyks Can you try with:

      uses: crazy-max/docker-metadata-action@commit-date-request

@Velyks
Copy link
Author

Velyks commented Nov 19, 2024

would you mind try docker/metadata-action@e2f1776f12f30b5ac969ca7a00d71db4e60ae80e with debug log level and paste output here?

##[debug]fetch commit 09c405963fe4ca966d930538058e089d5a6e2aec metadata from lyst/spidermon
##[debug]failed to find commit date, {"sha":"09c405963fe4ca966d930538058e089d5a6e2aec","node_id":"MDY6Q29tbWl0ODI3OjA5YzQwNTk2M2ZlNGNhOTY2ZDkzMDUzODA1OGUwODlkNWE2ZTJhZWM=","commit":{"author":{"name":"Thomas Sands","email":"[email protected]","date":"2024-11-19T16:02:08Z"},"committer":{"name":"GitHub Enterprise","email":"[email protected]","date":"2024-11-19T16:02:08Z"},"message":"Merge c502e2222d4be0c48706e2f0f54172e95475b9d9 into 03d6a4b00a975a6f28735022a5ca11c20b4e9c5a","tree":{"sha":"e41d1d34a1b5a2fa624913a1a83623a6970d8cab","url":"https://git.lystit.com/api/v3/repos/lyst/spidermon/git/trees/e41d1d34a1b5a2fa624913a1a83623a6970d8cab"},"url":"https://git.lystit.com/api/v3/repos/lyst/spidermon/git/commits/09c405963fe4ca966d930538058e089d5a6e2aec","comment_count":0,"verification":{"verified":false,"reason":"unsigned","signature":null,"payload":null}},"url":"https://git.lystit.com/api/v3/repos/lyst/spidermon/commits/09c405963fe4ca966d930538058e089d5a6e2aec","html_url":"https://git.lystit.com/lyst/spidermon/comm...
Warning: failed to get commit date for 09c405963fe4ca966d930538058e089d5a6e2aec, fallback to current date

@trim21
Copy link
Contributor

trim21 commented Nov 19, 2024

thanks

@Velyks
Copy link
Author

Velyks commented Nov 19, 2024

Thanks for looking into this so fast.

@trim21
Copy link
Contributor

trim21 commented Nov 19, 2024

need a new patch release I think

@crazy-max
Copy link
Member

Should be good with latest patch release. Let us know if that fixes the issue on your side 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants