Repository navigation
fix(tus): return 460 for checksum mismatches instead of 500 - #843
Open
Mortimer-RR wants to merge 1 commit into
Open
Mortimer-RR wants to merge 1 commit into
Mortimer-RR wants to merge 1 commit into
Conversation
When FinishUpload rejected an upload because its checksum did not match, it returned the errtypes error unchanged, which tusd reports as a generic 500 Internal Server Error. The upload session is deleted at that point, so clients that retry a 500 kept retrying an upload that no longer exists. Map errtypes.ChecksumMismatch to 460 Checksum Mismatch, the status the tus checksum extension defines, and errtypes.BadRequest to 400, so clients can tell that they have to start a new upload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 7 tasks
Author
|
The test-integration failure (5 × "index out of range [0] with length 0" at make build-ci && cd tests/integration && \
go test -race -count=1 ./grpc/ -args -ginkgo.seed=1790950586→ 95 passed, 5 failed on main, identical to this PR. The "gateway with a basic user |
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.
Fixes #842
When
FinishUploadrejected an upload because its checksum did not match, tusd reported ageneric 500, although the upload session was already deleted. Clients that retry a 500 kept
retrying an upload that no longer exists.
Changes
pkg/storage/pkg/decomposedfs/upload/upload.goFinishUpload:errtypes.ChecksumMismatch→ERR_CHECKSUM_MISMATCH, 460 (tus checksum extension);errtypes.BadRequest→ERR_BAD_REQUEST, 400.The plain-PUT datatx paths keep their existing 419 for checksum mismatches.
Client impact: the desktop client classifies 460 as a normal (retried) error. The web
client already refused to retry 5xx, and tus-js-client doesn't retry 4xx other than
409/423, so for web uploads only the reported status changes.
Tests
pkg/storage/pkg/decomposedfs/upload/upload_status_test.go: the mapping for a checksummismatch, an invalid checksum format and an unsupported algorithm (fail on
main).pkg/rhttp/datatx/manager/tus/tus_status_test.go: the real tusd handler over HTTP: awrong checksum gets 460 (500 on
main), a correct one 204.go test -raceclean on both packages;pkg/storage/...,pkg/rhttp/...,internal/http/services/...pass.🤖 Generated with Claude Code