Skip to content

πŸ› fix(redirects): paginate listRedirects to prevent silent truncation - #2

Merged
kud merged 1 commit into
mainfrom
fix/list-redirects-pagination
Aug 1, 2026
Merged

kud merged 1 commit into
mainfrom
fix/list-redirects-pagination

Conversation

@kud

@kud kud commented Aug 1, 2026

Copy link
Copy Markdown
Owner

πŸ“„ Description

listRedirects requested /domain/domains/{domain}/webredirs with no pagination parameters. Gandi caps that endpoint at 50 results and returns them with no error, no warning, and no indication the list is partial β€” so gandi redirect list silently under-reported whenever a domain held more than 50 redirects.

Measured on a real domain: the API held 64 redirects, the CLI reported 50. The 14 missing entries were invisible to both the table output and --json, so any script consuming the JSON got a confidently wrong answer. Notably, the missing entries included a redirect the user had just edited, which is how the bug surfaced.

The fix pages through with ?page=N&per_page=100, accumulating results until a short page signals the end. It deliberately does not cap silently: if pages never run short after 100 iterations, it throws an error naming the domain, on the principle that a truncated list is indistinguishable from a complete one and so must never be returned quietly.

Tests added in src/lib/api.test.ts:

  • single short page returns everything with exactly one request
  • a full page followed by a partial page concatenates to the full total, asserting the page/per_page query params on both calls
  • an exact multiple of the page size terminates correctly on the following empty page
  • pages that never run short throw rather than return a truncated list

πŸ“½οΈ Screencast

No visual changes.

βœ“ How to Validate

  1. npm install && npm run build
  2. gandi redirect list <domain> on a domain with more than 50 redirects β€” confirm the count matches what's actually configured (previously capped at 50).
  3. npm test β€” see the new pagination coverage in src/lib/api.test.ts (45 passing, up from 41).
  4. npm run lint β€” clean.

πŸ› οΈ Developer Checklist

  • Code is readable and maintainable
  • Tests included and passing (npm test β€” 45 passing, up from 41)
  • PR is atomic and focused on a single feature or bug
  • Commits follow Conventional Commits

Validated locally: npm run lint clean, npm test (45 passing), npm run build (tsc) clean, and verified live against a real domain β€” the CLI now returns 64/64 redirects and the previously-missing record is visible. No further manual/exploratory testing beyond that was performed.

@kud
kud marked this pull request as ready for review August 1, 2026 19:35
@kud
kud merged commit 08116da into main Aug 1, 2026
1 check passed
@kud
kud deleted the fix/list-redirects-pagination branch August 1, 2026 19:35
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.

1 participant