Skip to content

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

@Velyks

Description

@Velyks

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions