test: fail on JSONDecodeError chain from empty 429 (#108) - #557
Draft
alexander-nikitin-thenvoi wants to merge 2 commits into
Draft
test: fail on JSONDecodeError chain from empty 429 (#108)#557alexander-nikitin-thenvoi wants to merge 2 commits into
alexander-nikitin-thenvoi wants to merge 2 commits into
Conversation
Add a red-on-purpose pytest that hits get_agent_me through the real BandLink REST client with an ALB-style empty 429 body. Asserts the raised ApiError has no JSONDecodeError in __cause__/__context__ and no JSONDecodeError in the formatted traceback. Co-authored-by: Alexander Nikitin <alexander-nikitin-thenvoi@users.noreply.github.com>
Surface the dual JSONDecodeError/ApiError traceback in the pytest failure message so the #108 symptom is visible in the red run. Co-authored-by: Alexander Nikitin <alexander-nikitin-thenvoi@users.noreply.github.com>
7 tasks
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
JSONDecodeError traceback shown on empty 429 response bodies (#108)
This PR is test-only and red on purpose. It does not implement a production fix. It pins the #108 failure so a later change can turn it green.
Expected vs actual
Content-Length: 0) raises a cleanApiErrorwith noJSONDecodeErrorin__cause__/__context__and no intermediateJSONDecodeErrortraceback.main,band-client-rest==0.0.26):get_agent_mestill calls_response.json()for 429, catchesJSONDecodeError, and re-raisesApiErrorwithoutfrom None. Python exception chaining prints both tracebacks.Confirmed locally and in CI:
ApiError.status_code == 429,__cause__isNone,__suppress_context__isFalse,__context__isJSONDecodeError: Expecting value: line 1 column 1 (char 0).Test
tests/platform/test_rest_empty_429.pyThe test mocks an empty 429 on the real
BandLink→agent_api_identity.get_agent_mepath (pytest-httpx,max_retries=0to isolate decode/chaining from #107 retry behavior).CI (expected red)
Required
CI / testjobs (Ubuntu/Windows × 3.11/3.12) failed on only this new test:Lint, packaging, crewai, and parlant jobs passed. The assertion fails because
ApiError.__context__isJSONDecodeError(formatted traceback includes "During handling of the above exception, another exception occurred").Related Issues
Relates to #108
Testing
uv run pytest tests/ --ignore=tests/integration/) — this PR is expected to fail the new testChecklist