Skip to content

blob/fileblob: list keys in key order when a name sorts before a directory - #3854

Merged
vangent merged 1 commit into
google:masterfrom
THEpranavsomalraju:fix-fileblob-list-order
Nov 22, 2026
Merged

vangent merged 1 commit into
google:masterfrom
THEpranavsomalraju:fix-fileblob-list-order

Conversation

@THEpranavsomalraju

Copy link
Copy Markdown
Contributor

Fixes #3853.

filepath.WalkDir walks each directory's entries in file name order, so the directory a gets visited before the file a-b, even though a-b sorts before a/... as a key. Without a delimiter, the one-slot swap in ListPaged can't fix this when a key is more than one position out of place. The early page stop then puts the token past a-b, and paged listing ends up dropping or repeating keys.

This replaces WalkDir with a small walk that sorts each directory's entries by the key they map to (the name, plus "/" for directories). Objects now always come out in key order, so the swap and the extra condition on the early stop are no longer needed.

I added TestListNoDelimiterKeyOrder, which compares unpaged List and every page size against the sorted keys. It fails on master and passes with this change, and the existing tests still pass, including the delimiter case from #3791. I put the test in fileblob instead of drivertest because a new drivertest case would need new recordings for the cloud drivers.

…ctory

filepath.WalkDir visits directory "a" before file "a-b", but as keys
"a-b" sorts before "a/...". Without a delimiter, the one-slot swap
couldn't fix that and the early page stop then skipped or repeated keys.
Walk each directory's entries in key order instead, so objects are always
visited in key order and the swap and the stop guard are no longer needed.

Fixes google#3853
@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.64516% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.59%. Comparing base (3133066) to head (c8a42f3).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
blob/fileblob/fileblob.go 80.64% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3854      +/-   ##
==========================================
+ Coverage   81.52%   81.59%   +0.06%     
==========================================
  Files         100      100              
  Lines       12241    12261      +20     
==========================================
+ Hits         9980    10004      +24     
+ Misses       2260     2256       -4     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vangent
vangent merged commit 78a9a25 into google:master Nov 22, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

blob/fileblob: paged listing skips or repeats keys when a name sorts before "/"

2 participants