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:
-
network/gitlab.go—UploadRawArtifacts: 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. -
commands/helpers/artifacts_uploader.go—Run(): TheUploadFailedcase returnedretryableErr{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 argumentInstead of the actionable error:
WARNING: Retrying... error=open /path/to/artifact: permission denied
FATAL: open /path/to/artifact: permission deniedFix
- Changed
UploadRawArtifactsreturn 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(), theUploadFailedcase now returns the original error fromUploadRawArtifactsinstead ofos.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?
- Unit test:
TestArtifactsUploaderFailedWithError— verifies that whenUploadRawArtifactsreturns an error, it propagates throughRun()and appears in the retry/fatal output. - 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)