Tags: civo/civogo
Tags
Fix/listvpcips pagination (#287) * Auto-paginate ListVPCIPs (follow-up to #285) ListVPCIPs hits a different endpoint (/v2/vpc/ips) than the classic ListIPs (/v2/ips) and was missed in the audit for #285. Same shape of bug — single un-paginated request, server returns only the first page, caller silently sees a truncated list. This is the path the terraform-provider-civo civo_reserved_ip data source migrated to via FindVPCIP. End-to-end verification against staging with civogo v0.7.1 still showed customers unable to resolve Reserved IPs past the first page, even after the api-go off-by-one fix landed — because the SDK never asked for page 2 of /v2/vpc/ips. Routes ListVPCIPs through the same paginateAll helper introduced in #285. FindVPCIP benefits transparently since it wraps ListVPCIPs. Adds two regression tests covering the trailing-item case via both the direct ListVPCIPs call and the FindVPCIP convenience wrapper. Originating customer report tracked in civo&599 (civogo) and civo&598 (api-go side). Closes the gap exposed during staging verification. * Cover ListDatabaseBackup and add ListAllActions Audit follow-up to civogo#285 + the ListVPCIPs commit in this branch. ListDatabaseBackup /v2/databases/{id}/backups paginates server-side unconditionally and the SDK previously sent no per_page param, so any database with > 20 backups silently truncated. Affects civo-cli `civo db backup list` and `civo db backup delete` via FindDatabaseBackup. Routed through paginateAll using the same caller-transparent pattern as ListIPs. ListAllActions ListActions takes *ActionListRequest with PerPage/Page fields that are optional. Callers passing a zero-valued request hit only the first page silently. Rather than change ListActions semantics (which would break any external Go consumer relying on explicit pagination), added a sibling ListAllActions that iterates internally — pairs with ListActions the way ListAllInstances pairs with ListInstances. Filters on the request are preserved across page fetches; Page/PerPage on the filters are overridden by the iterator. Both fixes covered by regression tests in pagination_test.go using the existing newMultiPageServer helper. No active downstream callers of ListAllActions today; ListDatabaseBackup fix unblocks civo-cli for accounts with > 20 backups per database. * Drop CHANGELOG.md additions This repo's CHANGELOG.md hasn't been updated by other PRs since 2021 — maintaining release notes for these pagination fixes here would be inconsistent with the rest of the codebase. Releases are documented via git tags + GitHub Releases instead. Removes the bullets I added in #285 (now part of v0.7.1) plus the new bullets added earlier in this branch. * Add per-file regression tests for ListAllActions and ListVPCIPs/FindVPCIP The mechanism-focused boundary tests sat in pagination_test.go, but the conventional location for API-contract regression tests is the per-file test file (matching the existing TestListActions / TestListVPCIPs / TestFindVPCIP patterns). action_test.go gains: - TestListAllActions basic API contract, single page - TestListAllActions_AcrossPages verifies iteration across 3 pages - TestListAllActions_PreservesFilters verifies filter fields on ActionListRequest are forwarded to every page request and that Page/PerPage on the filters are overridden by the iterator (callers cannot accidentally short-circuit pagination by passing a small per_page) vpc_test.go gains: - TestListVPCIPs_IteratesAllPages verifies the /v2/vpc/ips path correctly aggregates items across all pages - TestFindVPCIP_OnSecondPage covers the customer-visible terraform-provider symptom: data "civo_reserved_ip" with an id whose owning IP sits past the first server page must now resolve cleanly Removed the corresponding TestListVPCIPs_TrailingItem / TestFindVPCIP_FindsItemPastFirstPage / TestListAllActions_MultiPage from pagination_test.go (now redundant with the per-file versions). TestListDatabaseBackup_TrailingItem stays in pagination_test.go since no database_backup_test.go file exists in the package. All tests pass; no source changes.
Auto-paginate the no-arg List* helpers (#285) ListIPs, ListAccounts, ListApplications, ListDatabases, ListKubernetesClusters and ListObjectStores previously sent a single GET /v2/... with no pagination parameters and silently returned whatever fit on the server-side first page (default 20 items). For accounts with more resources than that — typical in production — page 2 onward was invisible to civogo callers including civo-cli (`civo ip ls`) and terraform-provider-civo (`civo_reserved_ip`, `civo_kubernetes_cluster`, `civo_object_store`, `civo_database`). The customer ticket that surfaced this: an account with > 20 Reserved IPs in fra1 / lon1 could not see one specific IP via the CLI or Terraform. Tracked in api-go epic civo&598 (server-side off-by-one, fixed in civo/api-go!1354) and civogo epic civo&599 (this change). The fix introduces a shared `paginateAll` helper in `pagination.go` and routes the six no-arg `List*` functions through it. The merged response always reports `Page=1, Pages=1, PerPage=len(Items)`. Iteration is sequential and capped (100 pages / 10,000 items) with an explicit ErrPaginationCapExceeded rather than spinning forever. Two existing magic-number workarounds were retired in the same change: - ListAllInstances no longer uses ListInstances(1, 99999999). - FindObjectStoreCredential no longer uses ListObjectStoreCredentials(1, 10000). Both depended on api-go's paginator early-return path and would silently re-truncate the day server-side adds a per_page cap. They now share the same iterator. Includes regression tests covering: single page, multi-page in order, trailing-item-on-last-page (the customer's case), and hard-cap exhaustion. Updated affected fixtures that asserted the old buggy semantics (Pages>1 on a single-item response, PerPage=20 on the merged result). Co-authored-by: david.woolger@civo.com <david.woolger@civo.com>
PreviousNext