Skip to content

feat(api): resumable bulk uploads for files over the import cap (#1012) - #1270

Merged
athvin merged 2 commits into
mainfrom
feat/1012-bulk-upload
Nov 26, 2026
Merged

athvin merged 2 commits into
mainfrom
feat/1012-bulk-upload

Conversation

@athvin

@athvin athvin commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Closes #1012

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Resumable bulk uploads: POST …/uploads (declare source, bytes, sha256) → PUT …/uploads/{id}/parts/{n} (raw bytes, any order, retry-safe) → GET …/uploads/{id} (parts_received, for resume) → POST …/complete (verifies, then the same 202 receipt as an import) · DELETE aborts. 64 MiB parts (≤ import cap), 10,000 parts, 24h expiry with orphan sweep. Docs section with a shell example.

Why

#1012: a file over the HTTP import cap (256 MiB default) had no supported path to results — only internal drop directories.

Proof

  • pg_bulk_upload (new): a file several import caps long is refused by /imports (413), then arrives via parts sent out of order with an out-of-range, a wrong-size and a corrupt part; completion names the missing part, then the digest mismatch (parts kept), then succeeds; the job is pinned to the declared sha256/bytes and the published delivery equals the file; a second complete returns the same receipt; another dataset gets 404; abort removes the session.
  • uploads unit tests (assembly, resume, expiry sweep, declaration refusals). make check: exit 0.

Risk & rollback

New routes only; the finish_delivery split is behaviour-preserving (the replay and import tests cover it). git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:24d16c2e-fec6-49d8-9797-060338df4848 on brians-MacBook-Pro · 2026-11-26T20:27:31Z

  • main is green with this change on it — the merge SHA, and the run
    that proves it. A later head SHA with this commit as an ancestor counts;
    a cancelled run with zero jobs does not: 4000f059 — rust 45889615501, frontend 45889615472, infra/devcontainer/marketing preview success
  • images built, or correctly never ran because nothing that goes into
    an image changed: 45889615366 success
  • deploy converged — proved by a line the running process emitted, not
    by the image digest and not by the workflow conclusion: deploy 45890396911 success (dev + prod); the live process at https://dupezero.com/api/openapi serves /uploads/{upload_id}/complete (probed 20:27Z)
  • the push-only surface no pull request can pre-test (deploy, drift,
    kind's nightly leg) is green, or knowingly red for a reason that is not
    this change: deploy green; drift/kind red before this merge for known reasons (Confirm the er-alerts email subscription and prove alert delivery #1056, kind probe red since 2026-11-10: KeyError 'token_hash' after the credential-omission fix #1106)
  • the board card reached Done through the automation rather than by
    hand, and the issue closed: API: resumable bulk file transfer through staged object storage #1012 CLOSED, card Done via the merge automation
  • follow-ups are open for everything deferred here — numbers: n/a — a presigned-S3 transport is an option noted in Context, not owed work
  • what was learned is written down where the next session will find it
    (a skill, a reference, memory) — or nothing new was learned: the docs-reference grouping test (every public path needs a workflow group) is now in this PR's history; nothing else new

Specific to this change

Context — plan, discoveries, measurements, files

Plan

Discoveries

  • Chose a server-side parts API over presigned S3 multipart: every deployment's drop root is a filesystem path (local volume or the shared mount), it needs no new Terraform or credentials, and staging access is then exactly the dataset's routes — no signed URL can be logged or leaked. A presigned-S3 transport can sit behind the same session contract later.
  • The spec derivation rejected a raw Body extractor; it now documents it as application/octet-stream. A handler that rebuilds a response from parts is unclassifiable, hence accept_delivery returning data and accepted_response building the typed 202.

Measurements

Files

🤖 Generated with Claude Code

POST …/uploads opens a session with the file's exact size and SHA-256 and
returns part_size, part_count and a part_url. Parts are PUT as raw bytes,
in any order, each exactly its size and safely re-sendable; GET reports
parts_received so an interrupted client resumes; POST …/complete
concatenates, checks size and digest (422 naming missing parts or the
mismatch, parts kept) and hands the bytes to the same delivery path an
import uses. The upload id is the delivery's Idempotency-Key and a receipt
is kept, so completing again returns the first receipt. Sessions live
under the dataset's drop root, are invisible to other datasets, expire
after 24h (410) and are swept when the next upload opens; DELETE aborts.

finish_delivery is split into accept_delivery + accepted_response so a
caller can act on the accepted delivery, and er-api-spec documents a raw
Body extractor as application/octet-stream.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

The marketing preview was removed because this PR is closed or merged.

The reference test holds every public path to a workflow group; the new
uploads resource had none.
@athvin
athvin merged commit 4000f05 into main Nov 26, 2026
42 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 26, 2026 20:14 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — ba89dd7d Deployed Nov 26, 2026 by athvin via remove closed PR previews #70
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.

API: resumable bulk file transfer through staged object storage

2 participants