Skip to content

Fix 500 errors when browsing empty CI artifacts image

Stan Hu requested to merge sh-handle-empty-artifacts-blob into master

What does this MR do and why?

When generating a ZIP metadata artifact, Workhorse will omit the size field if the file is empty due to the way omitempty works in Go. Attempting to view the file in the artifacts browser will result in a 500 error as a result.

Fix this by defaulting to a size of 0 if size doesn't exist. Update the test artifact ZIP and metadata to test this issue.

When spec/fixtures/ci_build_artifacts.zip was updated a few years ago, the corresponding metadata was not updated. This commit fixes the non-UTF-8 directory case and regenerates the metadata with the latest gitlab-zip-metadata version.

Relates to #460378 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Run a CI job that generates an empty image as an artifact:
image: ruby:latest

test:
  script:
    - touch test.png
  artifacts:
    paths:
      - test.png
  1. With master, attempt to view it in the CI artifacts browser. See the 500 error.
  2. With this branch, you should see:

image

Edited by Stan Hu

Merge request reports