Skip to content

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

Open
floze-the-genius wants to merge 2 commits 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 2 commits into
pmxt-dev:mainfrom
floze-the-genius:fix/1700-feed-client-malformed-error-json

Conversation

@floze-the-genius

@floze-the-genius floze-the-genius commented Jul 18, 2026

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 and preserving the original HTTPError as the cause.

Fixes #1700.

Testing

  • .venv/bin/pytest tests/test_feed_client.py -q - 4 passed
  • focused regressions cover malformed HTML, invalid UTF-8 (the UnicodeDecodeError path), and preservation of the existing valid-JSON API error behavior
  • .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 the original installation/test pass
  • earlier full Python SDK pass on the same production change: 268 passed, 66 deselected
  • wheel and sdist build; twine check dist/* passed
  • git diff --check

Project-wide Mypy is not claimed as a clean gate: in the same Python 3.12.13 / Mypy 2.3.0 environment, both current main and this PR report the same 121 existing errors, plus the unsupported configured Python 3.8 warning. The PR adds no Mypy delta.

AI Assistance Disclosure

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

floze-the-genius and others added 2 commits July 19, 2026 01:16
Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: air <air@MacBook-Air-Air.local>
@floze-the-genius

Copy link
Copy Markdown
Author

@realfishsam This remains one small production fix on current main, now with focused regressions for malformed HTML, invalid UTF-8, and preservation of valid-JSON API errors (4/4 passing). Black and diff checks pass, and a same-environment Mypy comparison is unchanged at 121 existing errors on both base and PR. The four repository workflows are waiting for maintainer approval before any jobs start. Could you approve the runs and review when convenient?

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