Fix: RestAPIHeaderLinkPaginator broken for non-'items' response keys#66
Open
baconcheese113 wants to merge 2 commits intoWiden:mainfrom
Open
Fix: RestAPIHeaderLinkPaginator broken for non-'items' response keys#66baconcheese113 wants to merge 2 commits intoWiden:mainfrom
baconcheese113 wants to merge 2 commits intoWiden:mainfrom
Conversation
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.
Summary
Fixes two critical bugs in
RestAPIHeaderLinkPaginatorthat have prevented Link header pagination from working with APIs that don't use theitemsresponse key. These bugs have existed since the paginator was introduced in PR #36 (July 2023).Bugs Fixed
Bug #1: Early exit when response lacks 'items' key (pagination.py)
Location:
RestAPIHeaderLinkPaginator.get_next_url()(lines 170-180)Problem: The method was hardcoded to check for an
itemskey in the response body. If not found, it would returnNoneimmediately, completely ignoring the Link headers.Impact: Pagination failed for any API that doesn't use
itemsas the response key, including:seatskey)Fix: Moved the response body parsing inside the conditional block that only applies when using the
fake_sinceworkaround. Now properly follows RFC 8288 Link headers regardless of response body structure.Bug #2: Malformed URL from ParseResult (streams.py)
Location:
_get_url_params_header_link()(line ~478)Problem: Calling
str()on aParseResultobject created malformed URL strings with nested ParseResult representations instead of properly extracted query strings.Fix: Added proper
ParseResulthandling usinghasattr()and.queryproperty, with backward-compatible fallback tostr()for other types.Testing
test_streams.pyvalidating both new functionality and backward compatibilityBackward Compatibility
✅ Non-breaking change - Existing implementations using
itemskey continue to work exactly as before. These fixes only enable previously broken use cases.Related Issues