Repository navigation
fix(python): exempt strict-mode nonce from numeric coercion (#520) - #541
Merged
Seth Juarez (sethjuarez) merged 3 commits intoSep 10, 2026
Merged
Conversation
…r CLI The microsoft org blocks the Actions GITHUB_TOKEN from opening pull requests, and an org member cannot install a GitHub App on the org, so release-please cannot run in CI here. Releases are instead cut by running the release-please CLI under a maintainer's own identity (which the org permits) to open the Release PR; the existing tag-triggered OIDC publisher handles PyPI once the maintainer tags the merge. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace the deleted release-please.yml CI description with the actual maintainer-run CLI process. Explain why there's no CI workflow (org blocks the Actions GITHUB_TOKEN from opening PRs and its tags don't trigger publish), and document the exact manifest-pr/manifest-release commands with the required --config-file/--manifest-file flags that produce the correct python/2.0.0 tag. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The strict-mode sanitization nonce is random hex from secrets.token_hex. _parse_attrs coerced every all-digit attribute value to int/float, which dropped a leading zero (e.g. "0123..." -> 123...) so _build_message's comparison rejected the parser's own untampered output with a false "Nonce mismatch — possible prompt injection detected" error. ~1 in 1,200 generated nonces hit this, causing intermittent strict-mode failures. Exempt the nonce key from coercion in _parse_attrs (keep it a string), matching the existing Java and Swift fixes; all other attributes are still coerced. This behavior is not vector-governed (the nonce is non-deterministic), so it is pinned by runtime-local regression tests mirroring the sibling runtimes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Fixes #520.
The bug
In strict parsing mode, a valid render nonce is rejected when the random hex nonce is all decimal digits with a leading zero (e.g.
0123456789012345).pre_render()generates the nonce viasecrets.token_hex(8)and stamps it as a quoted[nonce="..."]attribute._parse_attrs()then int-coerced every all-digit value — dropping the leading zero — so_build_message()'sstr(msg_nonce) != noncecomparison raised a false:~1 in 1,200 generated nonces hits this, causing intermittent strict-mode failures (~0.5% per 100-prompt batch). Confirmed reproduced against published
prompty==2.0.0.The fix
Exempt the
noncekey from numeric coercion in_parse_attrs(keep it a string); all other attributes are still coerced. This matches the existing Java and Swift fixes — Python was the laggard.Is this vector-governed?
No. The strict-mode sanitization nonce is random (
secrets.token_hex), so it can't be a deterministic shared@vector. Siblings pin it with runtime-local regression tests (NonceCoercionTests.swift,ParseVectorsTest.allDigitNonceWithLeadingZeroStillValidates). This PR adds the matching PythonTestNonceCoercionclass:_parse_attrs(8 crafted coercion modes)index=1,ratio=0.5,active=true)Validation
ruff check/ruff format --checkcleanCo-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com