A GitLab CLI command exits with 401 Unauthorized, so you start checking the token. The last response really was a 401, but it tells you nothing about an earlier attempt. If the first request returned a 500 and the client retried it, the two responses explain different parts of the failure.
What the client returned
A local test exercised the current GLab API client against a stub for the GitLab Secure Files listing endpoint. The stub returned a synthetic server error on the first request and a synthetic expired-token response on the second. Both requests used the same fixture job token. No requests went to a real GitLab instance.
| Setting | Error returned to the caller | HTTP statuses visible in the trace |
|---|---|---|
GLAB_DEBUG=true |
401 | The earlier 500 was absent |
GLAB_DEBUG=true GLAB_DEBUG_HTTP=true |
401 | 500, then 401 |
The same 401 appeared in both runs. Turning on HTTP diagnostics made the retry visible, and the fixture credential did not appear in the captured output. This test demonstrates how the reported pattern can arise. A live system can produce the same final 401 for other reasons.
Inspect the retry without downloading files
If the failure happens when listing secure files, run the listing from the same checkout and with the same authentication configuration. Its success output shows file metadata and it leaves the files on the server.
GLAB_DEBUG_HTTP=true glab securefile list 2> glab-http.log
Find the status line for each response to the listing request. If the trace starts with a 5xx, capture that status and any request correlation ID before investigating the final 401. If the first request is already a 401, start with the selected host and which credential the job actually used.
HTTP diagnostics can include request and response bodies. Keep the log private and check it for sensitive project data before sharing any excerpts.
The original report and GitLab's configuration documentation are linked below.
AI assistance was used to draft and check this article.
Top comments (0)