fix: Read pagination from the response instead of a client hook - #640
Open
razor-x wants to merge 3 commits into
Open
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y1RzepycXEYA3LStfjt8cY
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y1RzepycXEYA3LStfjt8cY
razor-x
changed the base branch from
main
to
claude/python-sdk-audit-o2iid9-06-param-guard
August 28, 2026 00:15
…ude/python-sdk-audit-o2iid9-07-paginator-hooks
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
The paginator captured the pagination envelope by appending a response hook to the shared client's
event_hooks, making the request, then calling.pop()(SDK audit finding H4). That side-channel had four defects, all reproduced by the audit:try/finally: any failed page request (4xx/5xx, timeout) leaked the hook onto the client permanently — every later response on thatSeaminstance was force-read and JSON-parsed by a dead paginator's hook..pop()removes the last hook, not the paginator's own: two interleaved paginators cross-deleted each other's hooks. The async client made this the default failure mode —asyncio.gatherover two paginators is normal usage.paginationvalue silently truncatedflatten()to one page with no error._pagination_cachegrew unbounded and used a"FIRST_PAGE"string sentinel that could collide with a real cursor.The redesign removes the side-channel entirely:
PaginatedList— alistsubclass carrying the response'spaginationenvelope as an attribute. Callers of*.list()see no difference (isinstance(x, list), iteration, equality all unchanged). This is a codegen template change gated onhasPagination, so it lands at every paginated route at once, and any future request-level behavior reaches paginated requests for free (the drift-resistance property from the JS fix wave).data.paginationdirectly: no hooks, no cache, no sentinel, nothing shared. A missing or non-object envelope raisesSeamHttpInvalidResponseError(from fix: Raise a Seam error for a success response that is malformed #638) instead of silently truncating.clientconstructor parameter is retained for signature compatibility but no longer used.Also bumps
@seamapi/fake-seam-connect2.0.5 → 2.0.6, which fixed/access_codes/listreturning no pagination envelope (the same upstream fix the JS wave landed as fake-seam-connect #283) — the new envelope check caught it immediately.Stacked on #639; diff shrinks as the stack merges.
Testing
New
test/paginator_isolation_test.py: two async paginators underasyncio.gathereach see their own pagination with zero hooks on the client; a failed page request leaves no hooks; missing/non-object pagination envelopes raise with pinned messages (sync + async); paginated routes still return a plainlistcarrying the envelope.Revert check: with the old paginator restored, the tests fail with the audit's exact symptoms — one leaked hook after a failed request (
assert 1 == 0with the lambda visible), interfering concurrent paginators, andDID NOT RAISEon the truncation case.Full suite: 232 passed; mypy, pylint (10.00), black clean; regeneration drift-free.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Y1RzepycXEYA3LStfjt8cY
Generated by Claude Code