Repository navigation
CLI: upload each distinct file once with jittered retries; PDF fingerprints ignore font subset timestamps (sc-9174, sc-9164) - #165
Open
ndbroadbent wants to merge 1 commit into
Open
ndbroadbent wants to merge 1 commit into
ndbroadbent wants to merge 1 commit into
Conversation
…rprints ignore font subset timestamps (sc-9174, sc-9164)
This branch has not been deployed
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.
Two CLI fixes, one version bump (0.2.24 → 0.2.25).
sc-9174: an upload with identical files fails on R2 429
WeasyPrint's build of 42 files held 14 identical
.txtfiles. The server answers an upload URL for every snapshot whose file it lacks, and identical files share one content-addressed key, so the CLI PUT the same key up to 14 times in parallel. R2 lets one client write an object about once a second, and the retries from #128 (6 tries, 0.5 s → 8 s, no jitter) retried in lockstep, so the upload failed.add_snapshotsuploads each distinct SHA-256 once per run, across registration batches too. Every snapshot is still registered by name with its hash; the others point at the same blob. The registration request sends each snapshot once, as before; it's the upload list that asked for the same SHA twice, and that's deduplicated now.put_blobinstead of adding a second layer. 429, 5xx and dropped connections still get 6 tries with exponential backoff (orRetry-After, at most 30 s), plus up to 50% random jitter so parallel uploads don't retry together.uploading out/sample-03.txt: the store refused it 6 times, the last with 429 Too Many Requests(an inline snapshot shows asname (from path)). The presigned URL no longer goes into the log.POST /snapshots(app/src/http/api/builds.rs) would cover them; I left app/ alone here.sc-9164: PDF fingerprints change every run when font subsets carry a timestamp
fontTools stamps the time it saves each subset into
head.modified, which changeshead.checkSumAdjustmentand the directory checksum forhead. So every run of WeasyPrint, fpdf2 and similar tools got new fingerprints.visualci-core::pdf): font programs under a font descriptor'sFontFile2orFontFile3are decompressed (Flate etc. via lopdf), thennormalize_sfntzeroeshead.modified,head.checkSumAdjustmentand theheadtable-directory checksum before hashing. It parses the sfnt table directory and findsheadby tag. It skips the font, leaving it to be hashed as it is, unless the version is 0x00010000,trueorOTTO, the whole directory fits the data, theheadrecord exists, the table holds at least 36 bytes in range (checked arithmetic) and the magic number is 0x5F0F3CF5. No indexing can panic. CFF (Type1C), Type 1FontFileand collections are hashed as before. A font program the normalisation doesn't change hashes exactly as before: the referenced-stream path feedsRplus the stream's digest, the same asfeed.pdf::fingerprint_without_font_programs), it lists them under "same drawing, embedded fonts differ" with a note that this is usually a subsetter's timestamp, and suggestsSOURCE_DATE_EPOCH. It doesn't list every page as differing. It still exits 1, because those PDFs would still re-render each run.SOURCE_DATE_EPOCH. skills/ is regenerated and the plugin is bumped to 0.1.54.Deploy impact (fingerprints are shared with the renderer)
ALGORITHMstaysvci-pdf-1. I reworded its doc comment: bump it when a change could let PDFs that draw differently match. This change only makes fewer bytes count, so an old fingerprint can equal a new one only for PDFs that draw the same. Bumping would have re-rendered every PDF; this way only the affected ones re-render.headtable. That's most PDFs with embedded TrueType subsets (WeasyPrint, Chrome/Skia, fpdf2, ReportLab TTF).checkSumAdjustmentis never zero, so these get a new fingerprint once, whether or not their font had a timestamp. PDFs with only CFF/Type 1 or non-embedded fonts keep their fingerprints.rendersis keyed by project, source fingerprint and renderer), so they upload, render and get charged rendered-page credits once. Their manifest groups (sc-8868) hash fingerprints, so those groups show as needed and are re-checked once. After that, timestamp-only runs match and stop re-rendering.base.image == head.imageor the pixel fingerprint), so a re-render of the same drawing compares unchanged. Nothing shows as changed and nothing needs re-approving. The text-snapshot "variant" lookup uses text fingerprints, not PDF ones.document_fingerprintfrom the samefingerprint_bytes, so the CLI 0.2.25 and the renderer agree on any file.blobs.pdf_fingerprintis written only where it's NULL, so blobs already rendered keep the old value. That only matters when a PDF is registered by hash alone without a fingerprint (current CLIs always send one), and the worst case is one extra render.Tests
identical_files_are_uploaded_once: 20 identical files throughadd_snapshotsagainst a fake API and store → registered 20, exactly 1 PUT.an_upload_the_store_refuses_once_succeeds_on_a_retry: a 429, then success → 2 PUTs.an_upload_the_store_keeps_refusing_fails_naming_the_file: persistent 429 → 6 PUTs, and the error namessample-00.txt, "6 times" and 429.ignores_the_time_a_font_subset_was_saved: a synthetic TrueType subset (generated in the test, with real table checksums andcheckSumAdjustment) in a minimal PDF as Flate-compressedFontFile2. Two copies that differ only inhead.modifiedand the two checksums get the same document and page fingerprints.a_font_with_other_glyphs_still_changes_the_fingerprint: differentglyfbytes → different fingerprint, and the fonts-left-out fingerprint still matches (the compare-runs case).malformed_fonts_are_left_alone_without_panicking: empty data, a truncated header, directory or head table, a numTables that overruns, overflowing or out-of-range head offsets, a head that's too short, a bad magic number. Each is left unchanged, and the PDFs embedding them still fingerprint as drawn.Gates on the build pool:
cargo fmt --all --check,cargo clippy --locked --workspace --all-targets -- -D warnings,cargo test --locked --workspace --exclude visualci-app(all pass), andnode scripts/skills.mjs --check. No app/ code changed.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.