Repository navigation
Conversation
Argos serves most screenshots through ImageKit (files.argos-ci.com), which picks the format of each response itself: a small PNG can come back as a JPEG. `argos build download` and `argos baseline download` wrote those bytes under the snapshot's `.png` name, so the file's type did not match its extension and its pixels were lossy. Ask ImageKit for the original with `tr=orig-true`. Presigned S3 URLs (large images, text snapshots) already serve the original, and an added parameter would break their signature, so they are fetched as they are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Closing in favor of argos-ci/argos#2774: the API now returns the original file URLs ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
argos build downloadandargos baseline downloadcould write a JPEG under a.pngname.Argos serves screenshots under 100 megapixels through ImageKit at
files.argos-ci.com/<key>. ImageKit picks the format of each response itself (vary: Accept), and for some small PNGs it returns a JPEG, even when the request sendsAccept: image/png. The commands wrote those bytes under the snapshot's name, so the file's type no longer matched its extension, and the pixels were lossy instead of the uploaded PNG. That breaks exporting a build or comparing its files with other screenshots.Reproduce
On
main, afterargos login:node packages/cli/dist/index.mjs build download 45160 --project argos-ci/argos-javascript --json -o out file out/chromium/locator-handler.png # JPEG image data, baseline, precision 8, 100x100, components 3The API reports
contentType: image/pngfor that snapshot. Its URL serves a JPEG, andtr=orig-truegets the original back:In that build, 3 of the 38 PNGs came down as JPEGs. With this change, all 38 are PNGs, and every one of the 43 files hashes (SHA-256) to its upload key, so the bytes on disk are exactly what was uploaded.
Fix
Before fetching a file,
getOriginalFileUrladdstr=orig-truetofiles.argos-ci.comURLs withURL.searchParams, which keeps any other query parameters. The backend's ownscripts/import-build.tsuses the same parameter to fetch originals. Other URLs are fetched as they are: larger images and text snapshots (ARIA YAML) come as presigned S3 URLs, which already serve the original. Adding a parameter to them fails with403 SignatureDoesNotMatch(checked). The JSON output still lists each snapshot'surlas the API gave it. Errors show the URL that was actually fetched.I didn't add a check that the response's content type matches the snapshot's
contentType. That field is whatever the uploader declared:argos uploaddeclares a.jpgasimage/jpegbut uploads PNG bytes (core converts every image to PNG), and S3 serves text snapshots astext/plain. So the check couldn't prove the bytes are original, and it could reject valid files.Should the API return original URLs?
Yes, I think so.
Snapshot.urlin the REST API is the ImageKit URL that the web app uses, where format conversion saves bandwidth. API clients don't benefit from conversion, and they expect the bytes behindurlto matchcontentType. Building it inserializeSnapshot(apps/backend/src/api/schema/primitives/snapshot-diff.tsin argos-ci/argos) withtr=orig-truewould fix this for every client, not only the CLI. This change is still worth keeping after that:searchParams.setleaves such a URL unchanged, and older API deployments stay covered.Type of changes
bugChecklist
Optional checks:
🤖 Generated with Claude Code