fix(core/layers): handle non-trailing-slash path in native recursive list#7705
Open
tonghuaroot wants to merge 1 commit into
Open
fix(core/layers): handle non-trailing-slash path in native recursive list#7705tonghuaroot wants to merge 1 commit into
tonghuaroot wants to merge 1 commit into
Conversation
…list The native-recursive arm of SimulateAccessor::simulate_list `(_, true, _)` forwarded the list path directly to the backend. For a path without a trailing slash (for example `dir/file`), a backend that natively supports recursive list (such as a WebDAV server honoring `Depth: infinity`) walks the subtree of `dir/file` and returns only that entry, silently dropping prefix-siblings like `dir/file2`. Both the simulated-recursive arm `(true, false, true)` and the non-recursive arm `(false, false, _)` already handle this: for a path without a trailing slash they list the parent directory and wrap the result in a PrefixLister so that entries sharing the path prefix are returned. The native-recursive arm now applies the same handling, making recursive list of a non-trailing-slash path consistent across all backends regardless of native capability. The in-memory service tolerated the bug because its native lister treats the trailing path component as a prefix, so it stayed latent until a real WebDAV backend with native `Depth: infinity` exercised it. A focused regression test using a WebDAV-style native-recursive mock backend is added: it fails before this change (the sibling is dropped) and passes after it. Discovered while investigating apache#4256. Signed-off-by: tonghuaroot <23011166+tonghuaroot@users.noreply.github.com>
2 tasks
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.
Which issue does this PR close?
Related to #4256. This PR does not close that issue; it fixes a latent
correctness bug in the recursive-list path that was found while investigating
#4256, and is a prerequisite for any future native WebDAV recursive-list work.
Rationale for this change
SimulateAccessor::simulate_listhas three arms. Two of them (thesimulated-recursive arm
(true, false, true)and the non-recursive arm(false, false, _)) already special-case a list path without a trailing slash:they list the parent directory and wrap the result in a
PrefixLister, so thatlisting
dir/filereturns every entry sharing that prefix (for exampledir/fileanddir/file2).The native-recursive arm
(_, true, _)did not. It forwarded the path straightto the backend. On a backend that natively supports recursive list and follows
directory/subtree semantics (a WebDAV server honoring
Depth: infinity),listing
dir/filewalks the subtree ofdir/fileand returns only that oneentry, silently dropping prefix-siblings such as
dir/file2. The result of arecursive list then depends on whether the backend's native lister happens to
be prefix-based or subtree-based, which is inconsistent.
The in-memory service did not expose this because its native lister is
prefix-based (
scan(prefix)returns every key that starts with the prefix), sothe bug stayed latent until a real WebDAV backend with native
Depth: infinityexercised it.
What changes are included in this PR?
(_, true, _)arm ofsimulate_list: when the path has a trailingslash, forward to the backend as before; when it does not, list the parent
directory and wrap the result in a
PrefixLister, matching the other twoarms.
mod testsinsimulate.rs) using a mock backendthat models WebDAV
Depth: infinitysemantics. It asserts that recursivelylisting
dir/file(no trailing slash) returns bothdir/fileanddir/file2. The test fails without this change and passes with it. A secondcase asserts that listing a trailing-slash directory path is unchanged.
Are there any user-facing changes?
Yes, a bug fix: for services that declare native recursive list, calling a
recursive list with a path that has no trailing slash now correctly returns all
entries sharing that path prefix, consistent with non-native-recursive
services. No API changes. No breaking changes.
AI Usage Statement
This change was co-authored with AI assistance. The contributor drove the work:
the bug was found while reproducing #4256 against real WebDAV servers
(nginx, ownCloud, Nextcloud) in Docker, where a recursive list of a
non-trailing-slash path against a native
Depth: infinitybackend dropped asibling entry. The contributor diagnosed the root cause in
simulate.rs,verified the fix and the regression test against the memory service and a real
Nextcloud backend, and reviewed the final implementation. An AI assistant
(Claude) helped implement the fix and draft the regression test and this
description.