fix: replace assert with proper exception in query client#1856
Open
glitch-ux wants to merge 3 commits intopydantic:mainfrom
Open
fix: replace assert with proper exception in query client#1856glitch-ux wants to merge 3 commits intopydantic:mainfrom
glitch-ux wants to merge 3 commits intopydantic:mainfrom
Conversation
…sponse_errors The `assert response.status_code == 200` in `handle_response_errors` is stripped when Python runs with the `-O` (optimize) flag, causing unexpected status codes (e.g. 401, 403, 500, 503) to silently pass through and produce confusing `JSONDecodeError` exceptions downstream. Replace with an explicit `if` check that raises `QueryExecutionError`.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.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.
Summary
assert response.status_code == 200with an explicitifcheck raisingQueryExecutionErrorin_BaseLogfireQueryClient.handle_response_errorsassertis stripped when Python runs with-O(optimize flag), causing unexpected HTTP status codes (401, 403, 500, 503, etc.) to silently pass through instead of raising an error — downstream code then fails with a confusingJSONDecodeErroror similarTest plan
handle_response_errors)python -O -c "assert False"that asserts are indeed stripped, confirming the bug existsQueryExecutionErrorwith a clear message