fix(ocdav): return 400 with a body when a TUS upload creation has an invalid name#655
Open
michaelstingl wants to merge 1 commit into
Open
Conversation
…invalid name The TUS upload creation handler rejected a name that failed validation with a bare 412 Precondition Failed and no body, while PUT, MOVE, COPY and MKCOL return 400 Bad Request with the validation error marshalled into the body. Clients could not tell the user why the upload was rejected, and 412 reads as a header precondition rather than an invalid name. Return 400 with the error body, the same way the sibling write handlers do. Fixes: opencloud-eu#654
618ea32 to
377c02b
Compare
Member
|
created opencloud-eu/opencloud#2889 for having a look at the tests ... |
rhafer
pushed a commit
to rhafer/opencloud
that referenced
this pull request
Jun 3, 2026
opencloud-eu/reva#655 changes the TUS create response for an invalid name from 412 to 400. Update the invalid-name scenario to match. Each example now carries its own expected status in an <http-status-code> column. Names that fail ValidateName expect 400. The three folder/file rows stay 412: filename() applies path.Base first, so "folder/file" becomes the valid leaf "file" and never reaches the changed branch. lowLevelCreationExtension.feature is unchanged; its missing-Upload-Length case still returns 412. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Description
Align the TUS upload-creation handler (
tus.go) with the other write handlers: on a name-validation failure, return400 Bad Requestwith the reason in the body instead of a bare412.Warning
This changes a status the OpenCloud acceptance suite pins, so it needs a matching update to the OpenCloud acceptance tests; until then
api-integrationfails. The scenariocoreApiWebdavUploadTUS/uploadFile.feature"upload a file with invalid-name" asserts412; moving it to400is the only change needed there, since its other checks (noLocation, file not created) stay valid. The same applies to the missing-length scenario inlowLevelCreationExtension.featureif that branch is aligned too.Related Issue
Motivation and Context
With a bare 412 and no body, clients cannot show the user why an upload was rejected. The linked issue has the details.
How Has This Been Tested?
go build,go vet,go test -raceof theocdavpackage, and the pinnedgolangci-lintv2.10.1 (GOOS=linux GOARCH=amd64): all pass, 0 lint issueshandleTusPostwith a backslash filename and asserts400plus the reason in the body; red on the unpatched handler (412), green with the fix412with an empty body unpatched and400withname validation failed: must not contain \patched, while a clean name returns201in bothScreenshots (if appropriate):
n/a. Server-side status and response-body change.
Types of changes
Checklist:
coreApiWebdavUploadTUS/uploadFile.featurescenario pins the old412and needs a matching update in OpenCloud to move it to400)Type:*label via ready-release-go; no fragment needed)🤖 drafted with Claude Code, reviewed before submitting.