fix: paginate list_projects to defeat YouTrack's 42-row cap #80

Merged
David merged 1 commit from fix/list-projects-pagination into main 2026-07-02 04:26:37 +02:00
Owner

Problem

list_projects (crates/youtrack-client/src/api.rs) issued a single GET /api/admin/projects with no $top. When $top is omitted the YouTrack server applies its default page size of 42 rows and silently truncates the response, so any project past row 42 became invisible to the CLI. Every project-resolution path funnels through this function: get_project, resolve_project_id, and thus project list/show, all project vcs * subcommands, and issue create project resolution. On instances with more than 42 projects these surfaced as false project '<name>' not found errors.

Confirmed in production: claude-run called yt project vcs list VAPP --enabled-only --json and got project 'VAPP' not found. The daemon's diagnostic dumped the exact set of short names yt received back, and it was exactly 42 entries (YouTrack's default $top). VAPP exists and the token can read it; it just sat past the 42-row window.

Fix

Convert list_projects to the paginate-until-short-page loop already used by fetch_all_sprints and list_issue_activities: page with $top=100/$skip and stop only on a short page. The fields selector is byte-identical to the old single-request form and the function signature is unchanged, so get_project, resolve_project_id, and the project/project vcs command modules need no edits.

Tests

Added two wiremock tests: list_projects_paginates_until_short_page (full first page of 100 plus a partial second page returns all 101, asserting both $skip=0 and $skip=100 requests fire) and get_project_resolves_short_name_on_second_page (regression for the VAPP failure: a short name landing on the second page resolves instead of erroring). just pre-commit (fmt, clippy -D warnings, build, test) passes.

Fixes YTCLI-26.

## Problem `list_projects` (`crates/youtrack-client/src/api.rs`) issued a single `GET /api/admin/projects` with no `$top`. When `$top` is omitted the YouTrack server applies its default page size of 42 rows and silently truncates the response, so any project past row 42 became invisible to the CLI. Every project-resolution path funnels through this function: `get_project`, `resolve_project_id`, and thus `project list`/`show`, all `project vcs *` subcommands, and `issue create` project resolution. On instances with more than 42 projects these surfaced as false `project '<name>' not found` errors. Confirmed in production: `claude-run` called `yt project vcs list VAPP --enabled-only --json` and got `project 'VAPP' not found`. The daemon's diagnostic dumped the exact set of short names `yt` received back, and it was exactly 42 entries (YouTrack's default `$top`). `VAPP` exists and the token can read it; it just sat past the 42-row window. ## Fix Convert `list_projects` to the paginate-until-short-page loop already used by `fetch_all_sprints` and `list_issue_activities`: page with `$top=100`/`$skip` and stop only on a short page. The `fields` selector is byte-identical to the old single-request form and the function signature is unchanged, so `get_project`, `resolve_project_id`, and the `project`/`project vcs` command modules need no edits. ## Tests Added two wiremock tests: `list_projects_paginates_until_short_page` (full first page of 100 plus a partial second page returns all 101, asserting both `$skip=0` and `$skip=100` requests fire) and `get_project_resolves_short_name_on_second_page` (regression for the `VAPP` failure: a short name landing on the second page resolves instead of erroring). `just pre-commit` (fmt, clippy -D warnings, build, test) passes. Fixes YTCLI-26.
fix(client): paginate list_projects to defeat YouTrack's 42-row cap
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 28s
Create release / Create release from merged PR (pull_request) Has been skipped
19c94aa3ee
list_projects issued a single GET /api/admin/projects with no $top, so the YouTrack server applied its default page size of 42 and silently truncated the response. Every project past row 42 became invisible to get_project, resolve_project_id, and thus project list/show, all project vcs subcommands, and issue create project resolution, surfacing as false "project '<name>' not found" errors on instances with more than 42 projects.

Convert list_projects to the paginate-until-short-page loop already used by fetch_all_sprints and list_issue_activities: page with $top=100/$skip until a short page, keeping the fields selector byte-identical so Project decoding and all consumers are unchanged. Add wiremock tests covering the 100+partial pagination and a get_project regression that resolves a short name landing on the second page.

#YTCLI-26
David merged commit 2625a8b0a4 into main 2026-07-02 04:26:37 +02:00
David deleted branch fix/list-projects-pagination 2026-07-02 04:26:37 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pandoras-box/youtrack-cli!80
No description provided.