Repository navigation
feat(pagination): expose whether a list response's count is exact or approximate - #82
Merged
Merged
Conversation
…approximate The API flags an estimated count only in the X-Results-CountType header. _request now records it on paginated bodies and every PaginatedResponse carries it as count_type, so callers stop treating a planner estimate as a real total. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PaginatedResponsegainscount_type:"exact"or"approximate", from the API'sX-Results-CountTyperesponse header, on every list method.Nonewhen the header is absent._requestrecords the header on paginated bodies (those with acount) under a private key, and each of the 54PaginatedResponseconstructions reads it from its own response dict. That keeps it correct under concurrent calls on one client, whichlast_response_headersisn't. Detail responses never carry the key.Why
Past 1,000 matches the contract, IDV, opportunity and notice lists may return a query-planner estimate as
count, flagged only in that header, and the estimate can be well off (count: 2914for a query that pages through 1,677 rows). Other lists and filtered queries stay exact well past 1,000, so callers can't infer exactness from the size of the number.Closes #79.
Testing
None, results never carry the private key, and a detail response never gets it. The three list cases fail without the change.uv run pytest -m "not integration": 504 passed;ruffandmypy tangoclean.count_type="approximate"at 2,914; a recipient-filtered IDV query, the full entity list (1.9M) and the vehicle list report"exact".🤖 Generated with Claude Code