Artifacts API: ETag caching is broken, same ETag value returned always
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
GitLab documentation suggests using the ETag and If-None-Match headers to avoid unnecessary load on the server when checking for changes: https://docs.gitlab.com/ee/development/polling.html
A regression was introduced many months ago, this caching approach no longer works when using the single artifact download API: /projects/:id/jobs/artifacts/:ref_name/raw/*artifact_path?job=name
Steps to reproduce
I have created a repository that reproduces this issue on public the GitLab.com instance.
- Fork repository https://gitlab.com/intgr/ci-artifacts-test
- Edit file
artifact.txt, commit and wait for the CI to pass - Send a request at the artifact API while saving headers (change repo name
intgr%2Fci-artifacts-testas needed)Observe that the returned ETag header isGET https://gitlab.com/api/v4/projects/intgr%2Fci-artifacts-test/jobs/artifacts/main/raw/output/artifact.txt?job=compileEtag: W/"12ae32cb1ec02d01eda3581b127c1fee" - Edt
artifact.txt, commit, wait CI again - Send a request with
If-None-Matchheader with the previous ETagGitLab responds withGET https://gitlab.com/api/v4/projects/intgr%2Fci-artifacts-test/jobs/artifacts/main/raw/output/artifact.txt?job=compile If-None-Match: W/"12ae32cb1ec02d01eda3581b127c1fee"304 Not Modifiedresponse code, as if the artifact had NOT changed! - If you retry the request from step # 3, note that the ETag header still has the same value. But the HTTP body content has actually changed!
Output of checks
This bug happens on GitLab.com
Edited by 🤖 GitLab Bot 🤖