Skip to content

feat(pagination): expose whether a list response's count is exact or approximate - #82

Merged
vdavez merged 1 commit into
mainfrom
feat/count-type
Oct 2, 2026
Merged

vdavez merged 1 commit into
mainfrom
feat/count-type

Conversation

@makegov-mark

@makegov-mark makegov-mark Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

What

PaginatedResponse gains count_type: "exact" or "approximate", from the API's X-Results-CountType response header, on every list method. None when the header is absent.

_request records the header on paginated bodies (those with a count) under a private key, and each of the 54 PaginatedResponse constructions reads it from its own response dict. That keeps it correct under concurrent calls on one client, which last_response_headers isn'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: 2914 for 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

  • New tests: an approximate and an exact header come through (case-normalized), a missing header gives 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; ruff and mypy tango clean.
  • Live against the API: an IDV query reports 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

…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>
@vdavez
vdavez marked this pull request as ready for review October 2, 2026 23:55
@vdavez
vdavez merged commit 6965fd2 into main Oct 2, 2026
11 checks passed
@makegov-mark makegov-mark Bot mentioned this pull request Oct 2, 2026
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.

Expose whether a list response's count is exact or approximate

1 participant