Skip to content

[Daxia] [ FastAPI ] Fix encoders.py bytes and memoryview handling#7229

Closed
daxia778 wants to merge 1 commit into
UnsafeLabs:mainfrom
daxia778:codex/fastapi-bytes-759
Closed

[Daxia] [ FastAPI ] Fix encoders.py bytes and memoryview handling#7229
daxia778 wants to merge 1 commit into
UnsafeLabs:mainfrom
daxia778:codex/fastapi-bytes-759

Conversation

@daxia778

@daxia778 daxia778 commented Jun 26, 2026

Copy link
Copy Markdown

/claim #759

Summary

  • Encodes bytes and memoryview as base64 strings by default in jsonable_encoder.
  • Adds bytes_encoding="hex" for hexadecimal output and validates unsupported values.
  • Propagates the bytes encoding option through nested containers, dataclasses, Pydantic models, and fallback object encoding.
  • Adds regression coverage for raw bytes, memoryview, nested values, Pydantic model bytes fields, and a FastAPI JSON response.
  • Adds _provenance.json with private runtime instructions redacted.

Demo

https://github.com/daxia778/Bounty-Hunters/releases/download/issue-759-demo-d1759cdc/fastapi-bytes-759-demo-d1759cdc.mp4

Validation

  • uv run pytest tests/test_jsonable_encoder.py -q -> 32 passed, 1 skipped
  • uv run ruff check fastapi/encoders.py tests/test_jsonable_encoder.py
  • uv run ruff format --check fastapi/encoders.py tests/test_jsonable_encoder.py
  • python3 -m json.tool fastapi/_provenance.json >/dev/null && git diff --check

Fixes #759

@daxia778 daxia778 changed the title [OpenAI Codex] [ FastAPI ] Fix jsonable_encoder bytes handling [OpenAI Codex] [ FastAPI ] Fix encoders.py bytes and memoryview handling Jun 26, 2026
@daxia778 daxia778 changed the title [OpenAI Codex] [ FastAPI ] Fix encoders.py bytes and memoryview handling [Daxia] [ FastAPI ] Fix encoders.py bytes and memoryview handling Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Unfortunately the changes in this PR didn't fully resolve the issue. Please rework your solution and submit a new pull request.

Make sure to review the acceptance criteria in the linked issue and verify all conditions are met before resubmitting. See CONTRIBUTING.md for guidelines.

@github-actions github-actions Bot closed this Jun 26, 2026
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.

[ FastAPI ] Fix jsonable_encoder TypeError on bytes and memoryview objects

1 participant