Skip to content

Phase 1 (A): signed S3 reads in run-generate-archive.yml - #40

Merged
neuromechanist merged 2 commits into
mainfrom
fix/issue-738-archive-signed-reads
Jun 11, 2026
Merged

neuromechanist merged 2 commits into
mainfrom
fix/issue-738-archive-signed-reads

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

Phase 1 (A) of epic nemarOrg/nemar-cli#736. Make run-generate-archive.yml read annexed blobs with authenticated S3 GetObjectCommand (the same AWS creds the step already uses to write the zip) instead of anonymous https.get against the public S3 URL.

Why

When nm000111 was approved, this workflow ran seconds after the publish cascade flipped the dataset's S3 prefix public, before the bucket-policy change propagated. The anonymous blob reads all returned HTTP 403, so the job shipped a hollow zip (0 annexed + 639 regular + 126 skipped) and exited 1. The job already held AWS_ACCESS_KEY_ID/SECRET in its env but used them only for the multipart upload. Signed reads are visibility-independent (an IAM principal with s3:GetObject is not subject to the anonymous-public bucket-policy carve-out), so the race disappears and private datasets read fine too. No new secret: the org AWS_ACCESS_KEY_ID already has GetObject on the objects/ prefix, as proven by scripts/zarr/generate_zarr.py (authenticated aws s3 cp, many successful runs).

Changes (only the inline stream-archive.js heredoc)

  • Require GetObjectCommand; drop the https/http requires and S3_BASE.
  • Replace the anonymous fetchUrl(<public URL>) blob fetch with a signed s3.send(GetObjectCommand) via a new getAnnexObject() helper that streams resp.Body into the archive.
  • getAnnexObject() adds a small bounded backoff (3 attempts) for transient cold-start/throttle errors.
  • Unchanged: annex-key resolution, archiver wiring, skip accounting, the skipped > 0 exit-1 guard, and the outer idempotency head-object guard. A genuinely missing blob still throws -> skipped -> incomplete -> exit 1 (only the cause of a skip changes from "not-yet-public" to "truly absent").

Closes nemarOrg/nemar-cli#738
Part of epic nemarOrg/nemar-cli#736

Test plan (real dispatches, no mocks)

Dispatched the branch's workflow (--ref fix/issue-738-archive-signed-reads) so the branch's script ran:

  • nm000111 v1.0.1 (the dataset that originally failed; 126 real EDFs): Archive complete: 126 annexed + 639 regular + 0 skipped -> complete zip. The original 2026-06-10 run on the anonymous path skipped all 126.
  • nm099999 v1.0.0 (E2E test dataset, 1 annexed EDF): 1 annexed + 8 regular + 0 skipped.

Private-at-S3 case: nm099999's prefix is anonymously readable (not in the deny-list), so it could not force the 403 locally; the genuine private reproduction is nm000111's 2026-06-10 failure (those blobs returned 403 anonymously while private, then 200 after the public flip). Signed reads on a private prefix are guaranteed by S3 IAM semantics and already demonstrated in production by the zarr converter using the same credentials.

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.

Phase 1 (A): Signed S3 reads in run-generate-archive.yml

1 participant