-
Notifications
You must be signed in to change notification settings - Fork 39
fix: always decompress gzip when GzipDecoder is explicitly selected #909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Lucas Leadbetter (lleadbet)
wants to merge
1
commit into
main
Choose a base branch
from
devin/1771447353-fix-gzip-decoder-always-decompress
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: airbytehq/airbyte-python-cdk
Length of output: 3227
🏁 Script executed:
Repository: airbytehq/airbyte-python-cdk
Length of output: 5560
🏁 Script executed:
Repository: airbytehq/airbyte-python-cdk
Length of output: 5320
🏁 Script executed:
Repository: airbytehq/airbyte-python-cdk
Length of output: 1183
Fix looks correct — but found a pre-existing issue in
GzipParserworth addressing.The change properly ensures that when
GzipDecoderis explicitly configured, decompression is always attempted regardless of response headers. Logic is sound: fallback is now the fullgzip_parserinstead ofgzip_parser.inner_parser.One thing flagged during verification:
GzipParser.parse()has a docstring-implementation mismatch. The docstring claims "If the data is not gzipped, reset the pointer and pass the data to the inner parser as is" (lines 38-39 incomposite_raw_decoder.py), but the actual implementation (lines 45-46) just callsgzip.GzipFile(fileobj=data, mode="rb")with no error handling or pointer reset. When non-gzip data hits this, it will raiseOSError(BadGzipFile) on first read, not gracefully fallback.This is pre-existing, but your change makes it more likely to surface: with
fallback_parser=gzip_parser, non-gzip data now goes throughGzipParser.parse()instead of bypassing it. If a user configuresGzipDecoderagainst an API returning plain (non-gzip) responses, they'll hit this hard crash.Could you either:
GzipParser.parse()to actually reset the pointer and pass plain data through (matching the docstring), orOSErroron non-gzip input?Pagination support is fine:
CompositeRawDecoder.by_headers()returnscls(fallback_parser, ...)which setsself.parser = fallback_parser, so the decoder's parser property will correctly exposegzip_parserwith itsinner_parser. The pagination check should pass as expected.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on the docstring-implementation mismatch in
GzipParser.parse()— that's a real pre-existing issue.However, I'm keeping this PR scoped to the minimal fix (changing the fallback parser) rather than expanding into
GzipParserchanges, for a few reasons:GzipDecoderbecause the API always returns gzip — so the fallback hittingGzipParseris correct behavior and will decompress successfully.GzipDecoderis selected) is a separate concern that existed before this PR — the previousby_headerspath already usedGzipParserwhen headers matched, so a response without gzip encoding was already handled by the fallback (which before just skipped decompression silently, potentially producing garbage).GzipParser.parse()to gracefully handle non-gzip input is a good improvement but would change behavior for allGzipParserconsumers and warrants its own review.I'd suggest either fixing the
GzipParserdocstring or implementing the graceful fallback as a follow-up. Happy to defer to the human reviewer on whether they'd prefer it bundled here.Devin session