fix: paginate list_projects to defeat YouTrack's 42-row cap #80
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/list-projects-pagination"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
list_projects(crates/youtrack-client/src/api.rs) issued a singleGET /api/admin/projectswith no$top. When$topis 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 thusproject list/show, allproject vcs *subcommands, andissue createproject resolution. On instances with more than 42 projects these surfaced as falseproject '<name>' not founderrors.Confirmed in production:
claude-runcalledyt project vcs list VAPP --enabled-only --jsonand gotproject 'VAPP' not found. The daemon's diagnostic dumped the exact set of short namesytreceived back, and it was exactly 42 entries (YouTrack's default$top).VAPPexists and the token can read it; it just sat past the 42-row window.Fix
Convert
list_projectsto the paginate-until-short-page loop already used byfetch_all_sprintsandlist_issue_activities: page with$top=100/$skipand stop only on a short page. Thefieldsselector is byte-identical to the old single-request form and the function signature is unchanged, soget_project,resolve_project_id, and theproject/project vcscommand 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=0and$skip=100requests fire) andget_project_resolves_short_name_on_second_page(regression for theVAPPfailure: 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.