fix: verify resume identity and upload retries#93
Open
goanpeca wants to merge 27 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens multipart-upload resume behavior by making resume discovery verify an unfinished large file’s “identity” (source size/part size metadata + upload options) and selecting the newest compatible candidate, preventing same-name mismatches.
Changes:
- Add SDK-managed resume identity metadata (source byte length + effective part size) and use it to conservatively filter/choose resume candidates.
- Extend resume candidate selection to prefer the newest compatible unfinished large file and validate uploaded part byte lengths against the local plan.
- Update simulator metadata + ordering to support the new resume identity contract, and add/extend regression + integration tests and documentation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/upload/upload.slow.test.ts | Updates slow resume test to include resume identity fileInfo and explicit contentType for compatible discovery. |
| src/upload/upload-coverage.test.ts | Adds coverage test ensuring same-name conflicting unfinished uploads are skipped based on resume identity. |
| src/upload/resume.ts | Implements resume identity keys, richer candidate criteria, newest-compatible selection, and part-length verification. |
| src/upload/resume.test.ts | Adds unit tests for newest-candidate selection and mismatch filtering (options + part lengths). |
| src/upload/large.ts | Writes resume identity metadata for SDK-started resumable uploads and passes full criteria into discovery. |
| src/types/upload.ts | Expands unfinished-large-file metadata typing (timestamps, encryption, retention/legal hold, etc.). |
| src/simulator/index.ts | Extends simulator unfinished-large-file metadata and changes listing order used by resume discovery. |
| src/object.ts | Documents stricter resume discovery contract at the object upload API. |
| src/bucket.ts | Documents stricter resume discovery contract at the bucket upload API. |
| README.md | Documents the conservative resume identity contract and guidance for stable fileInfo across retries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b910aab to
26c7055
Compare
Comment on lines
+183
to
+189
| * file version. That response-body retry is disabled by default and requires | ||
| * `retryResponseBodyFailures: true`. | ||
| * file version; this is the idempotency tradeoff B2 documents for upload | ||
| * retries. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
ResumeFileIdMismatchErrorfor incompatible explicitresumeFileIdvalues, and keep SDK-managed resume metadata out of durable B2 fileInfo while still reading legacy resume metadata on existing unfinished uploads.resumeMaxListPages,resumeMaxPartCandidates, andresumeMaxPartPages, with structured rejection diagnostics that distinguish requested and candidate names. ExplicitresumeFileIdverification now keeps the requestednamePrefixwhile jumping tostartFileIdso prefix-restricted keys can verify candidates.Linked issue:
Tests run:
pnpm exec vitest run src/upload/resume.test.ts src/upload/upload-coverage.test.ts src/simulator/fidelity.test.ts src/client.test.ts src/raw.test.tspnpm exec vitest run src/raw.test.ts src/upload/resume.test.ts src/upload/upload-coverage.test.ts src/simulator/fidelity.test.tspnpm exec vitest run src/raw.test.tspnpm exec vitest run src/client.test.ts src/upload/resume.test.ts src/upload/upload-coverage.test.ts src/raw.test.tspnpm exec vitest run src/upload/upload-coverage.test.tspnpm run test:coveragepnpm typecheckpnpm lintpnpm lint:docspnpm lint:spellingpnpm testpnpm run docsReview status:
b910aabc5aaf4fae5c69ed842644e867c6ce5cdd.Follow-up notes:
AbortSignal, such asAbortSignal.timeout(...), when they need a hard timeout.