Skip to content

fix(dav): Return 423/403 for failed renames in the same folder - #67682

Open
kukanggg89 wants to merge 1 commit into
nextcloud:masterfrom
kukanggg89:fix-rename-same-folder-500-67163
Open

kukanggg89 wants to merge 1 commit into
nextcloud:masterfrom
kukanggg89:fix-rename-same-folder-500-67163

Conversation

@kukanggg89

Copy link
Copy Markdown
Contributor

Summary

A WebDAV MOVE that only renames a file in the same folder goes through Node::setName(), which let every refusal escape as a 500: a locked file (LockedException), a mount point that cannot be moved (ForbiddenException), and a storage that refuses the rename (rename() returning false). The same MOVE to another folder goes through Directory::moveInto(), which already converts these to 423 and 403. setName() now does the same conversion: a refused rename throws Forbidden, StorageNotAvailableException becomes ServiceUnavailable, ForbiddenException becomes Forbidden, and LockedException becomes FileLocked. This follows the fix direction the maintainer confirmed in the issue.

TODO

None.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests (unit, integration, api and/or acceptance) are included
  • Screenshots before/after for front-end changes (n/a: no front-end change)
  • Documentation (manuals or wiki) has been updated or is not required (n/a: no user-facing behaviour change beyond the status code)
  • Backports requested where applicable (ex: critical bugfixes) (n/a: bugfix, backport decision left to maintainers)
  • Labels added where applicable (ex: bug/enhancement, 3. to review, feature: component) (n/a: maintainers set labels)
  • Milestone added for target branch/version (ex: 32.x for stable32) (n/a: maintainers set the milestone)

AI (if applicable)

Drafted with help from Claude. I reviewed and revised every change myself before opening this PR.

Verification

Five unit tests were added to NodeTest: a locked file now throws FileLocked (423), a refused rename throws Forbidden (403), a ForbiddenException from the storage throws Forbidden (403), a StorageNotAvailableException throws ServiceUnavailable (503), and a successful rename updates the node path. The test suite was not run locally (no PHP toolchain in this environment); CI runs it. Not validated on a live instance: the three cases from the issue were checked by code reading against View::rename() and Directory::moveInto(), not reproduced against a running server.

Node::setName() let LockedException, ForbiddenException and a refused
rename escape as a 500, while Directory::moveInto() already converts the
same failures to 423 and 403. Wrap the rename call the same way: a
refused rename throws Forbidden, StorageNotAvailableException becomes
ServiceUnavailable, ForbiddenException becomes Forbidden and
LockedException becomes FileLocked.

Adds five unit tests in NodeTest: one for each converted error plus a
successful rename.

Signed-off-by: parel <farelalfarizi89@gmail.com>
Assisted-by: Muse:Muse Spark 1.3
@kukanggg89
kukanggg89 requested a review from a team as a code owner December 4, 2026 07:34
@kukanggg89
kukanggg89 requested review from Altahrim and salmart-dev and removed request for a team December 4, 2026 07:34

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant