Skip to content

fix: replace assert with proper exception in query client#1856

Open
glitch-ux wants to merge 3 commits intopydantic:mainfrom
glitch-ux:fix/replace-assert-with-proper-exception-in-query-client
Open

fix: replace assert with proper exception in query client#1856
glitch-ux wants to merge 3 commits intopydantic:mainfrom
glitch-ux:fix/replace-assert-with-proper-exception-in-query-client

Conversation

@glitch-ux
Copy link
Copy Markdown

Summary

  • Replace assert response.status_code == 200 with an explicit if check raising QueryExecutionError in _BaseLogfireQueryClient.handle_response_errors
  • The assert is 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 confusing JSONDecodeError or similar

Test plan

  • Existing VCR-based query client tests continue to pass (they exercise the 200 success path through handle_response_errors)
  • Verify with python -O -c "assert False" that asserts are indeed stripped, confirming the bug exists
  • Manually confirm that a non-200/400/422 response now raises QueryExecutionError with a clear message

…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`.
devin-ai-integration[bot]

This comment was marked as resolved.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
logfire/experimental/query_client.py 0.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

glitch-ux and others added 2 commits April 10, 2026 10:29
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

1 participant