Repository navigation
Commit fd7b378
fix(service-storage): a chunked completion retried after it succeeded answers the same 200, and a completed upload takes no more chunks (#33249)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DU5CHkeh2msc49m4dh6kwEt)_
Fixes #33027
Area-lease pilot #33059, area A3.
## What changes
Two doors in `packages/services/service-storage/src/storage-routes.ts`,
both about a chunked upload session already `completed`:
| Door | Before | Now |
|:--|:--|:--|
| `POST /storage/upload/chunked/:uploadId/complete`, sent again after it
succeeded | `500 INTERNAL`; session re-stamped `failed`; file stays
committed | `200` with the same body as the first completion; nothing
written, backend not called; session stays `completed` |
| same, the retry lists a chunk the upload does not hold | `409
RESOURCE_CONFLICT` | unchanged (the parts check still runs first) |
| `PUT /storage/upload/chunked/:uploadId/chunk/:chunkIndex` on a
completed session | `200` + eTag; chunk stored for no file, parts record
rewritten | `409 RESOURCE_CONFLICT`, nothing stored or recorded |
| either door on a session `in_progress`, `failed` or `expired` | as
before | unchanged (`failed` still is not a lock: a retry after a
backend blip completes) |
The `200` body is built by one helper (`completedUploadBody`) for both
the assembling completion and the replay, so they cannot drift. The
replay answers the key the file row was committed with. No new error
code: `409 RESOURCE_CONFLICT` is the code the door already uses for "the
request conflicts with where the upload stands".
## Why
A client that lost the `200` and retried (the SDK `resumeUpload`
pattern) was told a committed, downloadable file had failed, and the
session ledger said `failed`. Root cause: the completion door did not
look at the session's terminal status; the adapter had already discarded
its multipart, threw "Upload session not found", and the catch stamped
`failed` over `completed`.
## Verification
- New pins in `storage-routes.test.ts`, `describe('[#33027] a completed
session')`: replay `200` deep-equals the first body,
`completeChunkedUpload` and `updateSession` not called, row + progress
`completed`, file `committed`; a retry with a wrong eTag still `409`,
row stays `completed`; chunk PUT `409 RESOURCE_CONFLICT`, `uploadChunk`
not called, `parts`/`uploaded_size` unchanged; CONTROL: a re-sent chunk
on an in-flight session still `200`.
- Ablation (guards replaced by `false`, fix committed first, restored
with `git checkout HEAD --`): the replay pin and the chunk pin go red
(`2 failed | 2 passed`); restored tree diff empty.
- Local, on `d3d6b13f` + changeset: `service-storage`
`storage-routes.test.ts`, `chunked-upload-integrity.test.ts`,
`storage-routes.metadata-outage.test.ts`,
`chunk-part-record-concurrency.test.ts`: 169/169 passed.
`service-storage` typecheck, eslint on both files,
`check-adr-0087-registration`, `check-changeset-no-major`,
`check-empty-changeset`, `check-issue-citations`, `check:doc-authoring`,
`check:route-envelope`, `check:error-status-conformance`,
`check:nul-bytes`: all exit 0. Everything else: CI.
Clause-②: yes (narrowing)
Metadata-protocol: none
Changeset `.changeset/33027-chunked-complete-retry.md`:
`@objectstack/service-storage` patch, `adr-0087: not-required
(no-migration-prescription)`. Narrowing = the chunk PUT on a completed
session, `200` → `409`; widening = the completion replay, `500` → `200`.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (not touched)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4d1D3AzXvEhBbz79Pmi
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4d1D3AzXvEhBbz79Pmi)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent a2be78d commit fd7b378
3 files changed
Lines changed: 133 additions & 7 deletions
File tree
- .changeset
- packages/services/service-storage/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
527 | 595 | | |
528 | 596 | | |
529 | 597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
144 | 157 | | |
145 | 158 | | |
146 | 159 | | |
| |||
1078 | 1091 | | |
1079 | 1092 | | |
1080 | 1093 | | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
1081 | 1109 | | |
1082 | 1110 | | |
1083 | 1111 | | |
| |||
1426 | 1454 | | |
1427 | 1455 | | |
1428 | 1456 | | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
1429 | 1467 | | |
1430 | 1468 | | |
1431 | 1469 | | |
| |||
1609 | 1647 | | |
1610 | 1648 | | |
1611 | 1649 | | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
1612 | 1664 | | |
1613 | 1665 | | |
1614 | 1666 | | |
| |||
1640 | 1692 | | |
1641 | 1693 | | |
1642 | 1694 | | |
1643 | | - | |
1644 | | - | |
1645 | | - | |
1646 | | - | |
1647 | | - | |
1648 | | - | |
1649 | | - | |
| 1695 | + | |
1650 | 1696 | | |
1651 | 1697 | | |
1652 | 1698 | | |
| |||
0 commit comments