Repository navigation
Description
Description
With the S3 storage driver, paging through _catalog silently skips a repository when its name is a prefix of another repository's name. The trigger is the character that comes right after the shared prefix in the longer name: if it sorts before / in byte order, the shorter repo gets dropped. In practice that means a hyphen - or a dot . (in our case a hyphen).
The repository is fine in storage and shows up in a single wide listing, but it never appears once you page through. We hit this via a service that walks the whole catalog and quietly ended up with an incomplete list. Downgrading to 2.8.x fixes it.
Reproduce
- Run registry 3.1.1 with an S3 backend
- Push two repos sharing a prefix, the longer with a - after it:
docker push $REG/team/app:latest
docker push $REG/team/app-extra:latest
- Page one at a time:
curl -s "$REG/v2/_catalog?n=1"
# => {"repositories":["team/app-extra"]} (S3 byte order: '-' < '/')
curl -s "$REG/v2/_catalog?n=1&last=team/app-extra"
# => {"repositories":[]} <-- team/app is gone, here and on every later page
- A single wide page still has both:
curl -s "$REG/v2/_catalog?n=100" => ["team/app-extra","team/app"].
Expected behavior
Following the catalog Link pagination to the end returns every repository exactly once
registry version
3.1.1 (also 3.0.0). The regression spans 3.0.0–3.1.1; 2.8.x is fine.
Additional Info
Two orderings which the catalog code assumes are identical have diverged. The S3 Walk (since 3.0.0) lists keys in byte order. The filter handleRepository in catalog.go uses lessPath which sorts / first.
For team/app vs team/app-extra they disagree: byte order emits app-extra first, lessPath orders app first. When a page ends on the longer name, the next page's lessPath check rejects the shorter one even though the S3 walk re-emits it after the cursor.
distribution 2.8 worked because its S3 Walk used Delimiter:"/" plus a per-level sort, consistent with lessPath. The flat byte-order walk (commit cf81f67a) and the start-after paging hint WithStartAfterHint, which the S3 driver passes as S3's StartAfter (commit e22f7cbc) both landed in 3.0.0. This bug is the same family as #4891 / commit d1dbbb19, but on a different code path, so that fix doesn't cover this.
We have a one-line fix and a rough regression test ready, we will send a PR soon.
Disclosure: the analysis and bisection were done with help from Claude Opus 4.8, then verified manually against the source code and we locally reproduced.
Activity
mrnicegyu11 commentedon Jun 29, 2026
proposing #4904 to fix it. The fix is a one-liner, I added a mostly 🤖 generated regression test that you guys could add, I am also fine if we leave it away though no worries :--)
fix(storage): don't drop catalog repos that prefix another name