Skip to content

Fix: -Limit ignored under AutoPaginate (#30) - #48

Merged
dmann000 merged 4 commits into
dmann000:mainfrom
juemerson-at-purestorage:fix/autopaginate-limit-guard
Jul 24, 2026
Merged

Fix: -Limit ignored under AutoPaginate (#30)#48
dmann000 merged 4 commits into
dmann000:mainfrom
juemerson-at-purestorage:fix/autopaginate-limit-guard

Conversation

@juemerson-at-purestorage

Copy link
Copy Markdown
Collaborator

Summary

  • Invoke-PfbApiRequest -AutoPaginate had no running-total guard against the caller's -Limit: Purity//FB REST treats limit as page size only and keeps returning a continuation_token past that point, so every Get-Pfb* -Limit N call was silently re-paging the full collection.
  • Adds a running-total check ($requestedLimit, read once from $QueryParams['limit']) that stops issuing further paginated requests once the total reaches the limit, and trims the final result to exactly that count.
  • Follow-up hardening: tightened the limit guard to reject non-positive values, closing a latent GetRange() crash risk (unreachable via any current public cmdlet, but cheap to close).
  • No cmdlet-surface change -- fix is entirely inside Private/Invoke-PfbApiRequest.ps1.

Fixes #30.

Test plan

  • New Pester regression tests in Tests/Invoke-PfbApiRequest.Tests.ps1 covering: (a) pagination stops early and trims to -Limit when the server keeps returning continuation_tokens past that point, (b) full-collection auto-pagination is unchanged when no -Limit is given.
  • Live-verified against a lab FlashBlade array (REST 2.26): a raw single-page request with limit=100 against a 340-item collection confirmed the server returns exactly 100 items and a continuation_token even though more items remain -- the exact root cause. Get-PfbSession -Limit 5 / -Limit 250 each returned exactly that many items with only one page request; Get-PfbSession with no -Limit still returned the full 340.
  • Full unit test suite: 386 passed, 0 failed, 2 skipped -- no regressions.

…follow-up)

Final-review finding: the truthy check on $QueryParams['limit'] admitted
a negative limit, which would make the post-loop GetRange() throw
instead of behaving as "no limit". Unreachable via any current public
cmdlet (all validate limit > 0 before setting the query param), but
tightening the private function's own guard removes the latent crash
and the separate limit=0 gap in one edit.
@dmann000
dmann000 merged commit c2550d5 into dmann000:main Jul 24, 2026
4 checks passed
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.

-Limit is ignored under AutoPaginate — paginator has no running-total guard

2 participants