Skip to content

fix(python): wrap malformed feed API errors#1725

Open
floze-the-genius wants to merge 1 commit into
pmxt-dev:mainfrom
floze-the-genius:fix/1700-feed-client-malformed-error-json
Open

fix(python): wrap malformed feed API errors#1725
floze-the-genius wants to merge 1 commit into
pmxt-dev:mainfrom
floze-the-genius:fix/1700-feed-client-malformed-error-json

Conversation

@floze-the-genius

Copy link
Copy Markdown

Summary

Keep Python FeedClient error handling aligned with the TypeScript SDK when a proxy or upstream returns a non-JSON error body. Malformed JSON and invalid UTF-8 now fall back to the HTTP reason while still raising the typed PmxtError.

Fixes #1700.

Testing

  • regression test: malformed HTML body produces PmxtError with the HTTP status/reason and preserves the HTTPError cause
  • .venv/bin/pytest tests/test_feed_client.py -q - 2 passed
  • .venv/bin/pytest tests -q - 268 passed, 66 deselected
  • .venv/bin/black --check pmxt/feed_client.py tests/test_feed_client.py
  • generated the Python OpenAPI client with OpenAPI Generator 7.18.0 before installation/tests
  • wheel and sdist build; twine check dist/* passed
  • git diff --check

Project-wide Mypy is not claimed: the current configuration targets unsupported Python 3.8 under the installed Mypy and reports 118 existing SDK errors, including one pre-existing no-any-return in feed_client.py:102.

AI Assistance Disclosure

OpenAI Codex assisted with issue investigation, implementation, regression-test creation, and validation. I reviewed the final diff and test results.

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: air <air@MacBook-Air-Air.local>
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.

SDK drift: Python's FeedClient._request crashes with unwrapped JSONDecodeError on a malformed JSON error body; TypeScript falls back gracefully

1 participant