fix: paginate getProjects/getClients so all results resolve#56
Merged
jack-arturo merged 1 commit intoJun 8, 2026
Merged
Conversation
Toggl v9 list endpoints paginate by page/per_page (sorted by name). getProjects and getClients issued a single un-paginated GET, so the API returned only the first page and silently dropped the tail. Any project or client past that page failed name resolution and surfaced as the "Project <id>" fallback in reports and summaries. Add a requestAllPages helper that walks pages until a short page, with a guard against endpoints that ignore `page` (prevents an infinite loop) and a MAX_PAGES backstop. Wire getProjects/getClients through it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jack-arturo
approved these changes
Jun 4, 2026
jack-arturo
left a comment
Member
There was a problem hiding this comment.
I reviewed the diff and ran the verification set locally after checking out the branch:
- npm run build
- npm test (33/33 passing)
- npm run lint (0 errors; existing warnings remain)
- npm audit --audit-level=high (0 high/critical; existing moderate brace-expansion advisory only)
I also approved the pending fork CI/Security runs; GitHub checks are now passing. The pagination helper is scoped to projects/clients and has focused coverage for multi-page, short-page, and non-advancing-page behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
getProjectsandgetClientsissue a single un-paginatedGETto the Toggl v9 list endpoints. Those endpoints paginate bypage/per_page(sorted by name) and return only the first page by default, silently dropping the rest.As a result, any project or client past the first page fails name resolution and surfaces as the
Project <id>fallback in reports and summaries. Workspaces with more projects than a single page hit this for everything after the first page.Fix
requestAllPages()helper that walks?per_page=200&page=Nuntil a short page is returned.pageand re-returns the same window, preventing an infinite loop) and aMAX_PAGESbackstop.getProjectsandgetClientsthrough it (clients had the identical bug).This is offset pagination (
page/per_page), verified against the v9/workspaces/{id}/projectsendpoint —page=2returns a distinct, later, name-sorted window.Tests
TDD: three tests written first and watched fail, then pass:
page.Full suite green (30 passed, 3 pre-existing skips),
tsc --noEmitclean, ESLint 0 errors.Notes / out of scope
getProjectsstill uses Toggl's defaultactive-only filter, so genuinely archived projects still won't name-resolve — left for a separate change (e.g. anactive=bothoption).PAGE_SIZEis hardcoded to 200 rather than wired to the documentedTOGGL_BATCH_SIZEenv var, since theTogglAPIconstructor doesn't currently receive config. Happy to thread it through if preferred.