Repository navigation
Description
Describe the bug
The ocdav name validation rejects a configured set of characters; the default set includes the backslash. On that rejection the write handlers respond differently. The TUS create handler returns a bare 412 Precondition Failed with no body. put.go, move.go, copy.go, and mkcol.go return 400 Bad Request with a naming message. The inconsistent status and the missing body leave clients unable to tell the user why an upload failed.
Steps to reproduce
Run against a space (the filename in Upload-Metadata is base64):
# TUS create, name contains a backslash
POST /dav/spaces/<spaceID> Upload-Metadata: filename <base64 of "...IM\000024">
-> 412 Precondition Failed, empty body
# same name without the backslash
PUT /dav/spaces/<spaceID>/...IM000024
-> 201 Created
# MOVE an existing file onto a backslash name (raw "\" and percent-encoded %5C)
MOVE /dav/spaces/<spaceID>/clean Destination: .../...IM\000024
-> 400 Bad Request ("destination naming rules")
Expected behavior
The TUS create path reports an invalid name the same way the other write handlers do: 400 Bad Request with the ValidateName error in the body. Clients can then surface the reason.
The TUS spec supports this. It leaves the status for a metadata-based rejection to the server (the server MAY reject an upload based on Upload-Metadata, with no prescribed code), and it reserves 412 Precondition Failed for one case: an unsupported Tus-Resumable version, where the response must also carry a Tus-Version header. A bare 412 for an invalid name overlaps that reserved meaning, so a TUS-aware client can read it as a version problem. 400 is also what TUS uses for a malformed creation request.
The other handlers were aligned in:
Actual behavior
In internal/http/services/owncloud/ocdav/tus.go (the ValidateName branch, current main), the handler calls w.WriteHeader(http.StatusPreconditionFailed) and returns, with no body. put.go, move.go, copy.go, and mkcol.go return 400 via errors.Marshal(...) on the same ValidateName/ValidateDestination failure. The TUS create path is therefore the only write handler that returns a 412 with no reason.
Setup
reva v2.46.x as bundled in OpenCloud 6.1.0 (rolling). Reproduced over HTTP with curl, and with the OpenCloud desktop client 3.0.3 and the web UI. Default NameValidation.InvalidChars (\f, \r, \n, \).
Additional context
The user-facing symptom was reported in:
With the bare 412 and no body, the desktop client shows an empty "server replied:" and blacklists the file, with no recovery until it is renamed. The web UI shows "Unbekannter Fehler" with only an X-Request-Id. The 412 ("Precondition Failed") also reads as a protocol or header precondition rather than an invalid name.
🤖 drafted with Claude Code, reviewed before submitting.
Activity
michaelstingl commentedon Jun 1, 2026
History
Name validation reached the TUS create path in one commit, "disallow reserved names", which wired the check to the
412already used by the nearby precondition checks in the same function. The same pull request changedput.goto return400with the marshalled body, so the two branches diverged by which neighbour each copied.The first upload and move name checks came earlier.
The acceptance scenario that pins
412was copied from the ownCloud 10 test suite.OpenCloud acceptance tests
The api-integration suite pins the current
412, so aligning the status turns these red until they move to400:coreApiWebdavUploadTUS/uploadFile.feature, scenario "upload a file with invalid-name" (15 examples across old, new, and spaces DAV paths)coreApiWebdavUploadTUS/lowLevelCreationExtension.feature, the missing-length scenario, if the nearby missingUpload-Lengthbranch is aligned too (it returns the same reserved412for a malformed creation request)The other checks in those scenarios (no
Location, file not created) stay valid, so the update is the status value only.Clients
From reading each client's handling of the create response, not from running them against a patched build, no client depends on the
412:412and400are both non-retryable4xx, handled identically.412is classified as an etag or checksum precondition ("the e-tag has changed"), so it schedules a remote re-discovery and a soft retry that cannot succeed for an invalid name.400classifies as a hard error.412maps to a conflict result, with the in-code note "for TUS, 412 typically indicates Upload-Offset precondition mismatch".400drops that mapping.412and400.So no client reads the create
412as an invalid name, and400is at least as safe everywhere.🤖 drafted with Claude Code, reviewed before submitting.
fix(ocdav): return 400 with a body when a TUS upload creation has an …
fix(ocdav): return 400 with a body when a TUS upload creation has an …