Skip to content

Fix re-pull upload tests under aws-cli 2.42 - #2410

Merged
neuromechanist merged 3 commits into
devfrom
fix/repull-upload-aws-cli
Nov 26, 2026
Merged

neuromechanist merged 3 commits into
devfrom
fix/repull-upload-aws-cli

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Unblocks release PR #2408: the re-pull CLI suites failed in CI with upload-failed ("2 git-held data file(s) could not be annexed or uploaded: Error.") on runner image ubuntu-26.04 20261122.9.1 (aws-cli 2.42.1).

Root cause

The S3 stand-in was wrong. The re-pull's invocation and real S3 are not affected.

  • The suites set AWS_MAX_ATTEMPTS=1. Under preferred_transfer_client = auto, aws s3 already selects the CRT transfer client, but before aws-cli 2.41.2 it fell back to the classic client when max_attempts = 1. The 2.41.2 changelog reads "Support max_attempts = 1 in the CRT transfer client".
  • Through CRT, every PutObject and UploadPart carries x-amz-content-sha256: STREAMING-UNSIGNED-PAYLOAD-TRAILER and Content-Encoding: aws-chunked, with a trailing x-amz-checksum-crc64nvme. Captured from 2.42.1: 5\r\nhello\r\n0\r\nx-amz-checksum-crc64nvme:M3eFcAZSQlc=\r\n\r\n (54 bytes for a 5-byte file). 2.41.0 with the same environment sent the plain 5 bytes with an x-amz-checksum-crc64nvme header.
  • The stand-in stored the framed body as the object. awsCliUpload's size check (isKeyPresentAtDeclaredSize) then found 54 bytes where 5 were declared and threw. describeError withholds every plain Error's message, so the refusal said only "Error."
  • With the decoding fixed, a forced-CRT multipart upload also showed the stand-in rejecting the CRT client's CompleteMultipartUpload: part ETags arrive unquoted and with a <ChecksumCRC64NVME> element.

Production

Production re-pulls are not at risk from this change.

  • No repository setting forces the classic client: nothing in src/, backend/src, .github or scripts sets preferred_transfer_client, awsCliUpload passes no max_attempts, and the two scripts that set AWS_MAX_ATTEMPTS set it to 10. So production aws s3 sync runs with the installed CLI's default selection, which for 2.41.2 and later is CRT; which client a given host picks depends on its aws-cli version, which the repository cannot show.
  • aws-chunked with a trailing checksum is S3's standard streaming upload encoding, and real S3 decodes it.
  • This branch made no request to real S3.

Changes

  • test/scrub/helpers/s3-standin.ts: PutObject and UploadPart decode aws-chunked bodies, as S3 does. The decoded length must equal x-amz-decoded-content-length (IncompleteBody otherwise). The trailing checksum is verified (crc32, crc32c, crc64nvme, sha1 or sha256; BadDigest on a mismatch) and counts as the request's checksum. CompleteMultipartUpload reads each <Part> by element and accepts ETags with or without quotes. The log records chunked.
  • src/lib/import-normalize.ts, src/lib/normalize-dataset.ts, src/lib/import-scrub.ts: annex and upload failures throw UploadFailed, which carries a detail built only from fixed words and counts. describeError appends that detail; paths and stderr remain withheld. Against the old stand-in, the refusal now reads "UploadFailed: 2 of 2 object(s) absent from the bucket or the wrong size (first: 24 byte(s) declared, 74 byte(s) held)".

Tests

  • test/scrub/s3/standin.test.ts adds three tests:
    • The real aws CLI with the CRT client pinned uploads a small file and a 17 MiB multipart file. The test asserts the bytes, the ETag, and that the request was chunked, so it exercises the case on any installed aws-cli.
    • Short and bad-checksum chunked bodies are refused.
    • The checksums match the published check values.
  • test/repull-execute-prepare.test.ts adds one test: an injected S3 write fault refuses with upload-failed, and both the refusal and the row's last_error say "UploadFailed: aws s3 sync exited 1" without naming any path or the S3 error text.
  • Mutation checks: with decoding disabled, both new stand-in tests fail. With the describeError detail branch disabled, the prepare test fails.

What I ran

  • bun run typecheck, bun run lint
  • Before the fix, test/repull-gates-cli.test.ts failed with aws-cli 2.42.1, which reproduced the CI failure locally on macOS. The 2.42.1 binary came from the official pkg, expanded with pkgutil --expand-full.
  • With aws-cli 2.42.1: these 10 files pass, 284/284: repull-gates-cli, repull-merge-bids-override-cli, repull-execute-prepare, repull-execute-cli, repull-abandon-cli, repull-accept-merge-trailers-cli, repull-accept-merge-trailers-patch-cli, import-normalize, normalize-dataset, data-hosts.unit. test/scrub/s3/standin.test.ts passes 10/10.
  • With aws-cli 2.41.0: test/scrub/s3/standin.test.ts passes 10/10.
  • With aws-cli 2.41.0: the same 10 files, still running when this PR opened; result to follow in a comment.
  • Not run: the full bun test. CI covers it.

Review

Round 1 (one full review): no Critical or Important findings. The three suggestions are fixed in 0db7f7d: a chunk size must be hex digits only ("5zz" no longer parses as 5), bytes after the trailer are refused, and the header comment says which checksums the stand-in does not verify (plain x-amz-checksum-* headers on unchunked bodies, part checksums at completion). Two new assertions cover the refusals; the stand-in suite passes (10). The production paragraph above is reworded per the review.

aws-cli 2.41.2+ sends aws s3 uploads through the CRT client even with AWS_MAX_ATTEMPTS=1, so bodies arrive aws-chunked with a trailing checksum and part ETags unquoted. The stand-in stored the framing as the object. It now decodes and checks them as S3 does. Stand-in tests pass with aws-cli 2.41.0 and 2.42.1.
Upload and annex failures throw UploadFailed with a fixed-word detail that describeError appends, so upload-failed no longer reads 'Error.'. Paths and stderr stay out. Tested by an injected S3 fault in repull-execute-prepare.
@neuromechanist

Copy link
Copy Markdown
Contributor Author

The aws-cli 2.41.0 run has finished: the same 10 files pass, 284/284 (aws-cli/2.41.0 source/arm64, 585 s). Both versions now pass the affected files locally.

Review round 1 on #2410: refuse a chunk size with non-hex junk and bytes after the trailer, and say which checksums the stand-in does not verify. Stand-in tests pass (10).
@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2410

Version: 0.10.40-PR2410.0db7f7d
Commit: 0db7f7d


🤖 Updated on each push.

This branch was previously deployed

1 inactive deployment
npm — 0db7f7dc Deployed Nov 26, 2026 by neuromechanist via publish #4987
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant