Repository navigation
Python: Reject bytes in prompt template argument encoding - #14669
Open
Eduard van Valkenburg (eavanvalkenburg) wants to merge 1 commit into
Open
Eduard van Valkenburg (eavanvalkenburg) wants to merge 1 commit into
Eduard van Valkenburg (eavanvalkenburg) wants to merge 1 commit into
Conversation
Eduard van Valkenburg (eavanvalkenburg)
requested a review
from a team
as a code owner
October 27, 2026 15:41
Eduard van Valkenburg (eavanvalkenburg)
deployed
to
github-app-auth
October 27, 2026 15:42 — with
GitHub Actions
Active
Copilot started reviewing on behalf of
Eduard van Valkenburg (eavanvalkenburg)
October 27, 2026 15:42
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow change matches the intended behavior and includes targeted regression coverage with no unresolved issues.
No open issues 🎉
What changed in this PR
This PR makes Python prompt argument encoding reject bytes, requiring callers to decode byte content explicitly before rendering.
Changes:
- Remove
bytesfrom the primitive types accepted by automatic encoding. - Add regression coverage across Semantic Kernel, Jinja2, and Handlebars templates.
- Verify decoded strings remain a single user message and integer rendering is unchanged.
| File | Description |
|---|---|
python/tests/unit/prompt_template/test_prompt_template_e2e.py |
Test byte rejection and preserved string and integer behavior across three engines. |
python/semantic_kernel/prompt_template/prompt_template_base.py |
Route byte arguments through existing unsupported-value handling. |
Review effort: Balanced
Eduard van Valkenburg (eavanvalkenburg)
enabled auto-merge
October 27, 2026 15:45
Darren Cohen (dargilco)
approved these changes
Oct 27, 2026
This branch was successfully 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.
Motivation and Context
Prompt template argument encoding supports text and a set of scalar values.
bytesvalues do not have an implicit text encoding and currently render using their Python representation. This change uses the existing unsupported-value path so callers must decode or otherwise handle byte content explicitly.Description
bytesfrom the primitive types accepted by automatic prompt argument encoding.Callers that currently pass
byteswith default content handling will now receive the existingNotImplementedError. Textual byte content should be decoded with the intended encoding before rendering.Validation:
cd python && uv run --python 3.12 --frozen pre-commit run -a— passed.cd python && uv run --python 3.12 --frozen pytest tests/unit/prompt_template -q— passed.cd python && uv run --python 3.12 --frozen pytest tests/unit --ignore=tests/unit/processes/dapr_runtime -q— passed.cd python && uv run --python 3.12 --frozen pytest tests/unit/processes/dapr_runtime -q— passed after installing the Dapr FastAPI and Flask test extras in the local uv environment.Contribution Checklist