upload-artifact icon indicating copy to clipboard operation
upload-artifact copied to clipboard

[bug] v4.3.1: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

Open knkarlsson opened this issue 11 months ago • 10 comments

What happened?

Intermittent failures when uploading artifacts using uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 #version 4.3.1

The errors we have seen (in different builds):

Error: Failed to FinalizeArtifact: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Error: Failed to CreateArtifact: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

What did you expect to happen?

Successful upload of artifacts

How can we reproduce it?

Not sure, these are intermittent errors for us, seen only a couple of times since we started using v4 about 2 weeks ago. The workflows in our project do a few hundreds of similar uploads per day, most of the time without problem.

Anything else we need to know?

The artifacts that were failed to be uploaded were just a couple of small files.

What version of the action are you using?

version 4.3.1

What are your runner environments?

linux

Are you on GitHub Enterprise Server? If so, what version?

No response

knkarlsson avatar Mar 12 '24 12:03 knkarlsson

For reference: https://github.com/keycloak/keycloak/pull/27692

codespearhead avatar Mar 12 '24 16:03 codespearhead

same issue here

sa1g0n1337 avatar Mar 13 '24 11:03 sa1g0n1337

I also just encountered this issue with this workflow run: https://github.com/nlnwa/warchaeology/actions/runs/8449566338/job/23143911184#step:11:14 Re-triggering the workflow run made the workflow green again.

The relevant part of the log is:

##[group]Run actions/upload-artifact@v4
with:
  name: deb-amd64
  path: dist/warchaeology_*amd64.deb
  if-no-files-found: warn
  compression-level: 6
  overwrite: false
env:
  flags: --snapshot
##[endgroup]
With the provided path, there will be 1 file uploaded
Artifact name is valid!
Root directory input is valid!
##[error]Failed to CreateArtifact: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Post job cleanup.

trym-b avatar Mar 27 '24 09:03 trym-b

Also encountering the issue, here's a screenshot of it if that helps:

upload-artifacts

markmssd avatar Apr 03 '24 15:04 markmssd

Same issue here. We have recently migrated to v4.3.1

kisPocok avatar Apr 04 '24 15:04 kisPocok

We upgraded the upload-artifacts action in our workflows to v4.3.3 about 3 weeks ago and have not seen any issue with the upload until today, then we see the issue again.

SHA256 hash of uploaded artifact zip is d0ef7a365ba40cc972e10f10f4a9867a0901957ca82081e63753e58ea86981ff
Finalizing artifact upload
Error: Failed to FinalizeArtifact: Unable to make request: ECONNRESET
If you are using self-hosted runners, please make sure your runner has access to all GitHub endpoints: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#communication-between-self-hosted-runners-and-github
Run actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
/usr/bin/docker exec  eb0012f229099353a2d91f498ce1232f5734bcb8b4cd8025a79e82bff1402c7c sh -c "cat /etc/*release | grep ^ID"
No files were found with the provided path: archivables/*. No artifacts will be uploaded.

knkarlsson avatar May 28 '24 09:05 knkarlsson

If that can be of any help, we ended up wrapping the download action in a composite action like this:

# This is a wrapper around "actions/download-artifact@v4" action, to retry if it fails to download

name: Download artifact
description: Download artifact
inputs:
  name:
    description: 'Name of the artifact to download.'
  path:
    description: 'Destination path. Supports basic tilde expansion.'
  pattern:
    description: 'A glob pattern to the artifacts that should be downloaded.'
  merge-multiple:
    description: 'If true, the downloaded artifacts will be in the same directory specified by path.'
    default: 'false'
runs:
  using: composite
  steps:
    - name: Download artifact ${{ inputs.name || inputs.pattern }}
      uses: actions/download-artifact@v4
      id: download-artifact
      continue-on-error: true
      with:
        name: ${{ inputs.name }}
        path: ${{ inputs.path }}
        pattern: ${{ inputs.pattern }}
        merge-multiple: ${{ inputs.merge-multiple }}

    - name: Download artifact ${{ inputs.name || inputs.pattern }} (Attempt 2)
      uses: actions/download-artifact@v4
      if: steps.download-artifact.outcome == 'failure'
      continue-on-error: false
      with:
        name: ${{ inputs.name }}
        path: ${{ inputs.path }}
        pattern: ${{ inputs.pattern }}
        merge-multiple: ${{ inputs.merge-multiple }}

Basically if it fails to upload the first time, it will retry again. It's not a real solution, ideally the actions/download-artifact@v4 action itself should be fixed, but at least our workflows are not randomly failing anymore.

To use it:

      - name: Download my-artifact
        uses: ./.github/actions/download-artifact
        with:
          name: my-artifact

markmssd avatar May 28 '24 11:05 markmssd

@markmssd We have seen this issue in our builds a few more times since last week, so I'm going to add the wrapper like you did. Thank you for your advice!

knkarlsson avatar Jun 03 '24 06:06 knkarlsson

Hi All - we are facing this issue on a new deployment. Multiple files will not upload - API is working though

dalekirkwood avatar Jun 18 '24 14:06 dalekirkwood

I am also having issues with upload-artifact@v4, failing upload after 5 times

gynt avatar Aug 16 '24 07:08 gynt