Skip to content

fix: avoid FileSchema string payload fallthrough#5615

Open
pragnyanramtha wants to merge 1 commit into
bentoml:mainfrom
pragnyanramtha:codex/file-schema-string-payload
Open

fix: avoid FileSchema string payload fallthrough#5615
pragnyanramtha wants to merge 1 commit into
bentoml:mainfrom
pragnyanramtha:codex/file-schema-string-payload

Conversation

@pragnyanramtha
Copy link
Copy Markdown

@pragnyanramtha pragnyanramtha commented May 17, 2026

What does this PR address?

FileSchema.decode() accepts str inputs and starts handling them as UTF-8 file content, but the next branch was a separate if instead of an elif. As a result, string payloads still fell through to the final invalid-file-type error instead of being written to a temporary file.

This keeps PurePath inputs as paths, handles str payloads as file content, and adds a regression test for that behavior.

Validation

  • .venv/bin/python -m pytest tests/unit/_bentoml_sdk/test_validators.py -q -> 2 passed in 0.42s
  • .venv/bin/python -m pytest tests/unit/_bentoml_sdk -q -> 3 passed in 2.64s
  • uvx ruff check src/_bentoml_sdk/validators.py tests/unit/_bentoml_sdk/test_validators.py -> All checks passed!
  • uvx ruff format --check src/_bentoml_sdk/validators.py tests/unit/_bentoml_sdk/test_validators.py -> 2 files already formatted

Before submitting:

  • Does the Pull Request follow Conventional Commits specification naming?
  • Does the code follow BentoML code style? Targeted ruff check and ruff format --check passed for the changed files.
  • Did you read through contribution guidelines and follow development guidelines?
  • Did your changes require updates to the documentation? No documentation changes needed for this bug fix.
  • Did you write tests to cover your changes?

@pragnyanramtha pragnyanramtha changed the title fix: decode string payloads in FileSchema fix: avoid FileSchema string payload fallthrough May 17, 2026
@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 17, 2026 03:12
@pragnyanramtha pragnyanramtha requested a review from a team as a code owner May 17, 2026 03:12
@pragnyanramtha pragnyanramtha requested review from Copilot and ssheng and removed request for a team May 17, 2026 03:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants