How to Call a Private Google Cloud Run Service From Outside Google Cloud With Identity Tokens
A program outside Google Cloud needs two things to call a Cloud Run service protected by Identity and Access Management (IAM): a…
When your client reads a collection from an API, the server often returns only part of the records in each response. The API's pagination rules tell the client how to ask for the next part and how to tell when no records remain. If the provider changes those rules, the server can still return valid responses while your client misses records, repeats them, or stops early.
To read the full collection without losing data, you need to follow the provider’s documented signal for the next page, pass returned tokens and links back unchanged, and test the full traversal against the current page-size and ordering rules. A provider may label a change “backward-compatible” under its own policy, so you still need to verify that your existing client returns every record in the right order.
Start by checking the endpoint documentation, changelog, version notices, and migration instructions. Confirm which API version your client sends, or whether the server falls back to a default version when you omit one. A provider may announce a pagination change in a version notice even when your client can still parse the response without errors.
Providers also use the word “compatible” in different ways. Google’s AIP-180 compatibility guidance separates wire compatibility, where a client can still parse the message, from semantic compatibility, where the response keeps the same meaning. If a provider lowers the default page size, the response format stays the same, yet an older client that only reads one page will silently drop the rest of the collection. Google’s AIP-158 pagination guidance gives another example: when a provider adds pagination to an endpoint that previously returned every record at once, clients that expect a single complete response will miss data. Those examples come from Google’s own API design guidance, and other providers follow different rules.
Each provider writes its own compatibility policy. GitHub ships breaking changes in new REST API versions and lists what it treats as non-breaking in its breaking-change policy. Its versioning documentation explains how long GitHub supports each version and how it sends Deprecation and Sunset response headers as a version approaches retirement. Those timelines and headers are specific to GitHub, so check how your own provider announces changes and deprecations.
A successful HTTP status does not mean the server honored the page size you asked for. A provider can enforce a maximum, apply a default when you omit the page-size parameter, or return fewer records than you requested. In GitHub’s pagination documentation, GitHub notes that most REST endpoints cap per_page at 100 and silently lower any larger value to that cap. Always check the endpoint reference for the real limit instead of guessing from the parameter name or trusting a 200 status.
You also need to verify how the API tells your client that it has reached the last page. Some APIs return a URL or token for the next page; others use a dedicated response field or header. Do not assume that a short page means the collection is finished. Under AIP-158, an API can return fewer records than you asked for, or even an empty page, while more results still exist. Your client should keep going until the endpoint’s documented end signal says no more records remain.
Before you edit any client code, write down four details from the current docs: the page-size parameter and its default, the maximum allowed value and how the server handles requests above it, the signal for the next page, and the signal for the last page. Test a request at the documented maximum. If the provider explains what happens when you go over that limit, test a request above it too so you can see whether the server silently caps the page or returns an error.
When a server returns a continuation URL or token, it embeds whatever internal state it needs to find the next page. Treat that value as opaque. Pass it back the way the provider instructs, without parsing its contents, building your own replacement, or assuming the format will stay the same. GitHub’s REST API returns a Link response header with a rel="next" URL whose query parameters vary by endpoint. Microsoft Graph returns an @odata.nextLink field and advises clients to pass the entire URL as-is.
Continuation values do not last forever, and a server may also bind them to the original request parameters. Check the provider’s rules on filters, sorting, headers, and rejected tokens. AIP-158 allows tokens to expire and suggests three days as a rule of thumb for APIs that follow it, while Square documents a five-minute lifetime for its cursors. Because every provider sets its own expiration window, you cannot assume a cursor will work if you retry it later. When the documentation lists a specific error for an expired or invalid continuation, catch that error and follow the provider’s recovery steps.
Some APIs add extra rules for headers and retries during pagination. Microsoft Graph documents two of them for directory results. First, the service does not automatically carry custom headers other than Authorization and Content-Type onto later page requests, so your client must resend required headers like ConsistencyLevel on every page. Second, a token returned during a retry is not guaranteed to work for the next page, so your client should continue from the token in the last successful response that was not a retry. Those rules are specific to Microsoft Graph, and you should check whether your own provider has similar constraints.
The server’s sort order decides which records land on each page. A stable total order gives every record a clear position, even when two records share the same sort value. IBM’s API Handbook recommends sorting paginated collections by a unique field by default, and adding a second unique field to break ties whenever the requested sort can produce duplicates. That is IBM’s guidance for its own APIs, so check what ordering guarantees your provider actually makes. Even with a stable sort order, the server rarely freezes a snapshot of the collection. If another client inserts or deletes records while you page through the results, those changes can shift which records appear on later pages.
To test traversal properly, run your client against a collection you control that holds more records than fit on a single page. Page through until you hit the documented end signal, then compare the collected IDs against the expected IDs in exact order. If you only compare the set of IDs, you will catch missing or duplicate records, yet miss records that shifted out of order. Run tests for empty collections, single-page collections, multi-page collections, and exact page-size boundaries. If the provider documents that the collection can change during traversal, test against that behavior instead of flagging every concurrent edit as a bug.
Your contract tests should verify both the response shape and the traversal behavior. Confirm that your client follows the documented next-page signal, respects the page-size rules, and stops only at the documented end. In production logs, record the endpoint, API version, page count, and safe flags showing whether the server repeated or rejected a continuation value, while keeping credentials and sensitive cursor contents out of the logs. A repeated continuation value often means your client is stuck in a loop. You can also cap the number of pages or requests your client will fetch in one run, and log an error whenever it hits that cap before seeing the end signal.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com