Skip to content

fix(web): FastAPI adapter serialization parity — negotiation, JSON config, RFC 7807 (v26.06.33)#60

Merged
ancongui merged 1 commit into
mainfrom
fix/fastapi-serialization-parity
Jun 7, 2026
Merged

fix(web): FastAPI adapter serialization parity — negotiation, JSON config, RFC 7807 (v26.06.33)#60
ancongui merged 1 commit into
mainfrom
fix/fastapi-serialization-parity

Conversation

@ancongui
Copy link
Copy Markdown
Contributor

@ancongui ancongui commented Jun 7, 2026

The final parity audit's top finding: the FastAPI adapter (the auto-config-preferred one) silently bypassed the serialization stack added in v26.06.27/28 — global JSON config, content negotiation, and RFC 7807 only worked on Starlette.

  • FastAPI controller now threads accept + the message-converter registry into handle_return_valueAccept negotiation (JSON/XML, q-values) + Content-Type request parsing (incl. XML request bodies).
  • FastAPI app now wires pyfly_json_serializer / pyfly_message_converters / pyfly_problem_details onto app.state → global pyfly.web.json.* config + RFC 7807 problem+json apply on FastAPI.
  • Extracted a shared install_serialization_state(app, context) used by both adapters (Starlette refactored to call it) so they can't drift again.

Tests

tests/web/test_fastapi_content_negotiation.py (3, real FastAPI TestClient): JSON⇄XML response negotiation, XML request-body parsing, problem+json when enabled. Starlette e2e + full web suite unchanged.

Gates

mypy --strict (614) ✓ · ruff + ruff format ✓ · full suite 3793 passed.

Wave B of the audit fixes. Next: @transactional CancelledError-commit + read_only; Kafka per-message isolation.

…JSON config, RFC 7807) + bump v26.06.33

Final-audit finding: the FastAPI adapter bypassed the v26.06.27/28 serialization stack.
- fastapi controller threads accept + message-converter registry into handle_return_value
  (Accept negotiation JSON/XML + Content-Type request parsing incl. XML).
- fastapi app wires pyfly_json_serializer/pyfly_message_converters/pyfly_problem_details onto
  app.state (global pyfly.web.json.* config + RFC 7807 now apply on FastAPI too).
- Extracted shared install_serialization_state(app, context) used by BOTH adapters so they
  can't drift again (Starlette refactored to call it).

Tests: tests/web/test_fastapi_content_negotiation.py (3: JSON<->XML negotiation, XML request
body, problem+json). Gates: mypy --strict (614), ruff + format, full suite 3793 passed.
@ancongui ancongui merged commit 775e56c into main Jun 7, 2026
5 checks passed
@ancongui ancongui deleted the fix/fastapi-serialization-parity branch June 7, 2026 10:27
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