Skip to content

artifact-upload: read path-source copies back as checksummed - #742

Closed
snowp wants to merge 1 commit into
mainfrom
snow/artifact-path-fallback-checksum
Closed

snowp wants to merge 1 commit into
mainfrom
snow/artifact-path-fallback-checksum

Conversation

@snowp

@snowp snowp commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

State snapshot uploads can be dropped permanently by Loop API with "trailing data after the zlib stream". When a path-sourced artifact can't be moved into the upload directory, the uploader falls back to a copy that appends a CRC trailer, but recorded the entry as raw, so the CRC was uploaded as part of the payload. The copy is now recorded as checksummed, so the CRC is verified and stripped before upload; a successful move is unchanged.

Mobile SDKs use absolute SDK directories, so the move normally succeeds and the fallback only runs when a rename really fails. logger-cli with a relative --sdk-directory hits it on every snapshot, which is how this showed up in a local end-to-end run. Crash profiles are also path-sourced and would have been affected the same way.

🤖 Generated with Claude Code

When a path-sourced artifact cannot be moved into the upload directory,
the uploader copies it and appends a CRC trailer, but recorded the entry
as raw. Raw entries are uploaded verbatim, so the CRC was sent as part of
the payload. State snapshots are path-sourced, and Loop API rejects them
as having trailing data after the zlib stream and drops them for good.

Record the copy as checksummed so the reader verifies and strips the CRC.
A successful move stays raw. Adds a test that forces the copy fallback and
checks the uploaded bytes match the source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 22:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test changes the process-wide working directory without restoring it and then deletes that directory, risking filesystem failures in both concurrent and subsequent tests.

1 open issue
What changed in this PR

Fixes path-source artifact uploads that fall back to copying, preventing the appended checksum trailer from being uploaded as payload data.

Changes:

  • Marks copied artifacts as checksummed so their trailers are verified and stripped before upload, while successfully moved artifacts remain raw.
  • Adds a regression test checking that copy-fallback uploads contain only the original bytes.
File Description
bd-artifact-upload/​src/​uploader.rs Records the correct storage format for copied and moved path sources.
bd-artifact-upload/​src/​uploader_test.rs Adds regression coverage for copy-fallback payload integrity.

Review effort: Balanced

Comment on lines +2579 to +2582
let process_dir = tempfile::tempdir().unwrap();
std::env::set_current_dir(process_dir.path()).unwrap();
let source_path = std::path::PathBuf::from("snapshot-outside-sdk-dir.zz");
std::fs::write(&source_path, b"zlib snapshot").unwrap();
@snowp

snowp commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #743, which fixes the same path-copy fallback bug in its new uploader staging code (copies the raw bytes and keeps the entry raw) and adds snapshot_copy_fallback_preserves_raw_wire_bytes. #743 also replaces uploader.rs, so this change would conflict.

@snowp snowp closed this Nov 16, 2026
@snowp
snowp deleted the snow/artifact-path-fallback-checksum branch November 16, 2026 19:05
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants