Propagate artifact read errors to user instead of hiding them (closes #27922)

What does this MR do?

When the runner cannot read an artifact file during upload (e.g., permission denied), the actual error was silently discarded and replaced with a meaningless "invalid argument" message. This MR propagates the real error so users can diagnose the issue.

Root cause

The error flow was broken at two points:

  1. network/gitlab.goUploadRawArtifacts: The actual error (e.g., open /path/to/artifact: permission denied) was logged to the output but the function returned only (UploadFailed, "") — the error object was discarded.

  2. commands/helpers/artifacts_uploader.goRun(): The UploadFailed case returned retryableErr{err: os.ErrInvalid} ("invalid argument"), completely replacing the original error with a useless message.

This meant users saw:

WARNING: Retrying...  error=invalid argument
FATAL: invalid argument

Instead of the actionable error:

WARNING: Retrying...  error=open /path/to/artifact: permission denied
FATAL: open /path/to/artifact: permission denied

Fix

  • Changed UploadRawArtifacts return type from (UploadState, string) to (UploadState, string, error) so the actual error is propagated to the caller.
  • Updated the interface definition, mock implementations, function type, and all call sites.
  • In Run(), the UploadFailed case now returns the original error from UploadRawArtifacts instead of os.ErrInvalid.

Why was this MR needed?

A customer reported an issue where artifact upload failed due to a file permission error (internal ticket). The failure was not obvious — it appeared as a generic 500 from Workhorse with no clear indication from the runner that it couldn't read the artifact file. The runner should clearly output an error if an artifact exists but fails to be read.

What's the best way to test this MR?

  1. Unit test: TestArtifactsUploaderFailedWithError — verifies that when UploadRawArtifacts returns an error, it propagates through Run() and appears in the retry/fatal output.
  2. Manual test: Create an artifact file without read permissions and run a job that attempts to upload it. Verify the runner output contains the permission-denied error.

What are the relevant issue numbers?

Closes #27922 (closed)

Merge request reports

Loading