Skip to content

test: fail on JSONDecodeError chain from empty 429 (#108) - #557

Draft
alexander-nikitin-thenvoi wants to merge 2 commits into
mainfrom
cursor/empty-429-jsondecode-108-2650
Draft

test: fail on JSONDecodeError chain from empty 429 (#108)#557
alexander-nikitin-thenvoi wants to merge 2 commits into
mainfrom
cursor/empty-429-jsondecode-108-2650

Conversation

@alexander-nikitin-thenvoi

@alexander-nikitin-thenvoi alexander-nikitin-thenvoi commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

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

  • Expected: an empty ALB-style HTTP 429 (Content-Length: 0) raises a clean ApiError with no JSONDecodeError in __cause__ / __context__ and no intermediate JSONDecodeError traceback.
  • Actual (current main, band-client-rest==0.0.26): get_agent_me still calls _response.json() for 429, catches JSONDecodeError, and re-raises ApiError without from None. Python exception chaining prints both tracebacks.

Confirmed locally and in CI: ApiError.status_code == 429, __cause__ is None, __suppress_context__ is False, __context__ is JSONDecodeError: Expecting value: line 1 column 1 (char 0).

Test

  • File: tests/platform/test_rest_empty_429.py
  • Command:
uv run pytest tests/platform/test_rest_empty_429.py -v --no-cov

The test mocks an empty 429 on the real BandLinkagent_api_identity.get_agent_me path (pytest-httpx, max_retries=0 to isolate decode/chaining from #107 retry behavior).

CI (expected red)

Required CI / test jobs (Ubuntu/Windows × 3.11/3.12) failed on only this new test:

FAILED tests/platform/test_rest_empty_429.py::test_empty_429_raises_api_error_without_json_decode_chain
==== 1 failed, 4874 passed, 535 skipped ... =====

Lint, packaging, crewai, and parlant jobs passed. The assertion fails because ApiError.__context__ is JSONDecodeError (formatted traceback includes "During handling of the above exception, another exception occurred").

Related Issues

Relates to #108

Testing

  • Unit tests pass (uv run pytest tests/ --ignore=tests/integration/) — this PR is expected to fail the new test
  • Lint passed in CI
  • Integration tests pass (if applicable)

Checklist

  • PR title follows Conventional Commits format
  • Code follows project style guidelines
  • Tests added/updated as needed
  • Documentation updated as needed
Open in Web Open in Cursor 

cursoragent and others added 2 commits August 23, 2026 07:06
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>
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.

2 participants