Skip to content

fix: preserve task response header bytes - #5711

Open
Ricky-7-Yan wants to merge 1 commit into
bentoml:mainfrom
Ricky-7-Yan:fix/task-response-header-encoding
Open

fix: preserve task response header bytes#5711
Ricky-7-Yan wants to merge 1 commit into
bentoml:mainfrom
Ricky-7-Yan:fix/task-response-header-encoding

Conversation

@Ricky-7-Yan

Copy link
Copy Markdown

What does this PR address?

Task-result response headers are serialized from ASGI's Latin-1 byte representation, but deserialization currently uses UTF-8 through the default str.encode(). A header such as b"caf\xe9" therefore returns as b"caf\xc3\xa9" after a round trip.

This change uses the serde's existing HEADERS_ENCODING in the response path, matching request deserialization and restoring byte-for-byte symmetry. It adds a focused regression test for a non-ASCII Latin-1 header value.

This revisits the voluntarily closed #5693 from @feiiiiii5 after revalidating the behavior on current main.

Verification:

  • direct async red/green round-trip reproduction — failed before the change and passed after it
  • ruff check src/_bentoml_impl/tasks/serde.py tests/unit/bentoml_io/test_tasks_serde.py
  • ruff format --check src/_bentoml_impl/tasks/serde.py tests/unit/bentoml_io/test_tasks_serde.py

AI assistance was used for implementation and test preparation; the reported commands were run locally.

Before submitting:

  • Does the Pull Request follow Conventional Commits specification naming?
  • Does the code follow BentoML's code style, pre-commit run -a script has passed? Focused Ruff lint and format checks passed; the full pre-commit suite was not run.
  • Did you read through contribution guidelines and follow development guidelines?
  • Did your changes require updates to the documentation? No user-facing documentation change is needed for this serialization bug.
  • Did you write tests to cover your changes?

@Ricky-7-Yan
Ricky-7-Yan requested a review from a team as a code owner August 28, 2026 17:59
@Ricky-7-Yan
Ricky-7-Yan requested review from bojiang and removed request for a team August 28, 2026 17:59
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