Repository navigation
fix(http-client-python): escape wire names in request-builder literals - #12504
Libba Lawrence (l0lawrence) merged 5 commits into
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
The delimiter change breaks an existing exact-output unit test, and the user-visible fix is missing the required package changelog entry.
2 open issues
What changed in this PR
This PR addresses #12473 by escaping wire names in Python request builders, preventing specification strings from becoming executable expressions or invalid Python syntax.
Changes:
- Uses
python_string_literalfor path keys, query/header keys, and keyword-argument lookups. - Adds regression tests verifying that unusual wire names round-trip as literal data.
| File | Description |
|---|---|
packages/http-client-python/tests/unit/test_string_literals.py |
Adds literal round-trip tests for query, header, path, and keyword-argument wire names. |
packages/http-client-python/generator/pygen/codegen/serializers/parameter_serializer.py |
Escapes wire names when generating request-builder literals. |
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The user-visible Python generator fix lacks the required Chronus changelog entry for @typespec/http-client-python, so it would be omitted from the package’s release notes.
1 open issue
1 resolved since last review
Review effort: Balanced
commit: |
|
All changed packages have been documented.
Show changes
|
Python emitter diffBaseline No changes to generated output. Rendered diff: inline on the run summary, or the emitter-diff-html artifact. Informational check (eng/emitter-diff); does not block the PR. |


Fixes #12473
param.wire_name is spliced raw into a single-quoted Python literal in serialize_query_header, so a quote in the wire name closes the literal early and the remainder becomes a live Python expression in the generated module (observed:
_params["x" + str(1024) + ""], URL carries computed x1024) or a SyntaxError at import; the fix routes all wire-name interpolations through the existing python_string_literal helper, with regression tests for quotes, backslashes and control characters.