Skip to content

feat: page-token pagination utilities #799

Done

Description

@uniqueg

Problem

foca.utils.pagination pages by offset (offset/limit). Offsets skip or repeat items when items are added or deleted between two requests, so the services built on FOCA page their lists with opaque page tokens instead, each with its own code: cloud-registry (GET /failures, pageSize/pageToken), drs-filer (GET /objects, elixir-cloud-aai/drs-filer#140) and proWES (GET /runs, page_size/page_token). They differ in details (token format, validation, maximum page size), and each had to fix the same bugs (e.g., elixir-cloud-aai/cloud-registry#420: malformed tokens answered with 500).

Proposal

Add keyset ("page token") pagination to foca.utils.pagination, next to the offset helpers:

  • Parse and check a page size against a configurable default and maximum (400 with the parameter named, without echoing the value).
  • Encode and decode opaque tokens for a stable sort key (e.g., MongoDB _id, or a time plus _id as tie-breaker), with an exact check (re.fullmatch, see fix: schema patterns accept a trailing newline #797) and 400 for malformed tokens.
  • Build the MongoDB filter and sort for the next page, and the next token from the last item.
  • Parameter names stay with the app (GA4GH APIs differ: pageToken vs page_token).
  • Docs in "Paginating lists"; then move cloud-registry, drs-filer and proWES to the helper in their own PRs.

Done when

  • Tests: first, middle and last page; items added or deleted between pages; malformed and fabricated tokens; size bounds.
  • Docs updated.

Activity

  1. added
    priority: low
    status: triage
    type: feature
    workload: hours
    on Nov 19, 2026
  2. added
    status: in progress
    and removed
    status: triage
    on Nov 25, 2026
  3. self-assigned this
    on Nov 25, 2026
  4. moved this from Backlog to In progress in ELIXIR On-Cloud: Low Priorityon Nov 25, 2026
  5. moved this from In progress to In review in ELIXIR On-Cloud: Low Priorityon Nov 25, 2026
  6. added this to the v0.23.0 milestone on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority: lowstatus: in progresstype: featureworkload: hours

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions