Repository navigation
Fix auto-pagination undercounting pages when the API caps page size - #91
Conversation
New-HaloGETRequest calculated the number of pages to fetch as Ceiling(record_count / <requested page_size>). The Halo API can silently cap the number of records returned per page below what was requested (e.g. asking for page_size=1000 but only ever getting 100 records back), which meant that calculation was frequently wrong and caused every Get-Halo* multi-mode cmdlet to silently return only the first page of results on any endpoint with more matching records than the API's real per-page cap - no error, just fewer results than actually exist. Capture the actual size of the first page returned and use that consistently for every subsequent page-count calculation instead of trusting the requested page size. A short final page no longer skews the count for pages before it. Fixes homotechsual#90 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The implementation directly addresses the undercount and includes focused regression coverage.
Pull request overview
Fixes silent result truncation when Halo caps API page sizes below the requested value.
Changes:
- Calculates page count using the first response’s actual item count.
- Adds regression coverage for a 250-record, three-page response.
File summaries
| File | Description |
|---|---|
Private/New-HaloGETRequest.ps1 |
Uses the effective API page size for pagination. |
Tests/HaloAPI.Unit.Tests.ps1 |
Verifies capped pages are fully retrieved. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #91 +/- ##
===========================================
+ Coverage 69.88% 69.92% +0.04%
===========================================
Files 229 229
Lines 3712 3717 +5
===========================================
+ Hits 2594 2599 +5
Misses 1118 1118
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
False positive due to assignment of do-while loop. Coverage is good. |
|
Fixes #90 |
Summary
New-HaloGETRequest's auto-pagination works out how many pages to fetch asCeiling(record_count / <requested page_size>). The Halo API can silently cap the number of records actually returned per page below the requestedpage_size(e.g. asking forpage_size=1000but only ever getting 100 back), so that calculation is frequently wrong and everyGet-Halo*multi-mode cmdlet ends up silently returning only the first page of results whenever the real result set is bigger than the API's true per-page cap — no error, just fewer records than actually exist.keeps paginating when the API returns fewer records per page than requested) that reproduces the bug: requestspage_size=1000against a mocked 250-record endpoint that only ever returns 100 per page, and asserts all 250 records come back across 3 requests.Confirmed empirically against a real Halo tenant before writing the fix:
Get-HaloTicket(no-PageSize) returned only 100 of 717 real tickets; requestingpage_size=1000directly againstapi/ticketsstill only returned 100 records per page even thoughrecord_countcorrectly reported 717.Fixes #90
Test plan
Invoke-PesteronTests/HaloAPI.Unit.Tests.ps1— all 452 tests pass (451 existing + 1 new), no regressions.DevOps/Quality/run-pssa.ps1— no new PSScriptAnalyzer findings introduced by either changed file.🤖 Generated with Claude Code