Skip to content

feat(tags): enhance tag listing API with detailed descriptions and validation for offset - #5706

Open
akrem-chabchoub wants to merge 4 commits into
masterfrom
fix/tag
Open

akrem-chabchoub wants to merge 4 commits into
masterfrom
fix/tag

Conversation

@akrem-chabchoub

@akrem-chabchoub akrem-chabchoub commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have added or updated fuzz targets for any code handling untrusted input.
  • I have filled out the description and linked the related issues.

Description

GET /tags now pages through the upload store index instead of loading and sorting every tag on each request. The scan stops once offset+limit entries 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 in openapi/Swarm.yaml.

Other changes

  • Negative offset and limit are rejected with 400. Previously a negative offset could panic.
  • Canceled requests return 408 and timeouts return 503, instead of a 500.
  • The 500 response no longer includes the internal error text.
  • ListSessions takes a context.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

  • This PR contains code that has been generated by an LLM.
  • I have reviewed the AI generated code thoroughly.
  • I possess the technical expertise to responsibly review the code generated in this PR.

@akrem-chabchoub
akrem-chabchoub marked this pull request as ready for review November 16, 2026 13:41
@akrem-chabchoub akrem-chabchoub added this to the 2026 milestone Nov 16, 2026
@akrem-chabchoub akrem-chabchoub linked an issue Nov 16, 2026 that may be closed by this pull request
3 tasks done
// 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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@martinconic martinconic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@akrem-chabchoub akrem-chabchoub changed the title feat(tags): enhance tag listing API with detailed descriptions and va… feat(tags): enhance tag listing API with detailed descriptions and validation for offset Nov 20, 2026

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

Development

Successfully merging this pull request may close these issues.

GET /tags loads every tag into memory, whatever the limit

2 participants