Repository navigation
fix(sdk): normalize image upload media types before decoding - #5747
Draft
Kayvan-Zahiri wants to merge 1 commit into
Draft
Kayvan-Zahiri wants to merge 1 commit into
Kayvan-Zahiri wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR address?
An image upload with
Content-Type: image/png; charset=binarysendsPNG; CHARSET=BINARYto Pillow as a format name and fails. Split off MIME parameters and normalize the case of the media type before selecting the Pillow decoder. Keep restricting the decoded image to the declared format.Closes #5746.
Eight regression/control cases use real PNG/JPEG bytes and Starlette uploads. On the original code, four fail and five existing/control cases pass. With this fix, all 10 tests under
tests/unit/_bentoml_sdkpass.Also exercised a local
@bentoml.apiHTTP endpoint acceptingPIL.Image.Image. The same PNG upload returns HTTP500 on the original tree and HTTP200 with[2, 3]after the fix. These are local ASGI requests; no BentoCloud/Modular deployment was used.Before submitting:
pre-commit run -ascript has passed? Changed-file pre-commit checks passed: Ruff lint/format, trailing whitespace, EOF. The whole-repository-arun was not performed; lock/buf hooks had no applicable changed files.AI assistance: Codex investigated, implemented and ran the checks above on Kayvan's behalf. No unaided human review or full repository test run is claimed. This draft is ready for maintainer feedback.