Repository navigation
feat(tags): enhance tag listing API with detailed descriptions and validation for offset - #5706
akrem-chabchoub wants to merge 4 commits into
Conversation
…lidation for offset
| // returns no items. The scan stops as soon as the page is full. If ctx is | ||
| // canceled before or during the scan, it returns nil and the wrapped context | ||
| // error, never a partial page. | ||
| func ListTagsPage(ctx context.Context, st storage.Reader, offset, limit int) ([]TagItem, error) { |
There was a problem hiding this comment.
Tag IDs come from a counter in NextTag, but the keys are decimal strings, so new tags sort into the middle of the list. With uploads running, offset paging repeats or skips tags. I checked it on a disk storer: page 1 (offset 0, limit 5) is [1 10 11 12 2]; after creating tag 13, page 2 (offset 5) is [2 3 4 5 6], so tag 2 shows up twice. On master new tags go at the end and paging stays stable. The newest tags also become hard to find. Could we look at a cursor parameter (after=) or a bounded heap over a keys-only scan before committing to this order? bee-js and Desktop both consume this endpoint.
There was a problem hiding this comment.
Good catch, reproduced. Added an after=<id> cursor: it seeks straight to the key, so it's still one page of reads, and each existing tag is listed exactly once while uploads run. offset still works.
I'd skip the heap: it still scans every key per request, which is what the issue asks us to remove.
…orting and retrieval
martinconic
left a comment
There was a problem hiding this comment.
Since this adds a query parameter (and changes the order and the limit bounds), could you bump info.version? The branch has 8.2.2 and master is at 8.3.0, so 8.4.0.
Checklist
Description
GET /tagsnow pages through the upload store index instead of loading and sorting every tag on each request. The scan stops onceoffset+limitentries are read.Behavior change
Tags are returned in index key order, the lexicographic order of their decimal IDs (
1, 10, 11, 2, 3…), not numeric order. Clients that page through the list should expect different page boundaries after this change. This is documented inopenapi/Swarm.yaml.Other changes
offsetandlimitare rejected with 400. Previously a negative offset could panic.ListSessionstakes acontext.Context. The mock storer matches the store's ordering.Open API Spec Version Changes (if applicable)
Motivation and Context (Optional)
Related Issue (Optional)
#5693
Screenshots (if appropriate):
AI Disclosure