Skip to content

fix(python): spread body parameters with Mapping protocol names use correct wire name#10248

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-python-emitter-mangled-names
Draft

fix(python): spread body parameters with Mapping protocol names use correct wire name#10248
Copilot wants to merge 4 commits intomainfrom
copilot/fix-python-emitter-mangled-names

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

  • Fix the bug in preprocess/__init__.py: stop padding wire-name keys in propertyToParameterName (only pad the Python parameter name values)
  • Add comprehensive unit tests in test_name_converter.py:
    • Added mangled_property_name() helper to avoid duplicated mangled-name construction
    • Test that all Mapping protocol names are TSP property reserved words (get padded as model properties)
    • Test that Mapping protocol names are NOT parameter reserved words
    • Parametrized test for all mapping names: wire keys not padded in propertyToParameterName
    • Test that parameter-name values in propertyToParameterName ARE padded when matching reserved parameter words
    • Regression test for the specific items wire name bug
    • Regression test for all Mapping names
  • Add new spreadDictMethods scenario to http-specs/specs/special-words/main.tsp
  • Add mock API handler in http-specs/specs/special-words/mockapi.ts
  • Regenerate special-words SDK for both azure and unbranded flavors (gitignored - done locally)
  • Add integration tests in azure and unbranded mock API test files (sync + async)
  • Add test_as_attribute_dict_with_mapping_protocol_property_names to test_model_base_serialization.py:
    • Verifies azure.core.serialization.as_attribute_dict() still returns Python attribute names (items_property, etc.)
    • Verifies model.as_dict() still returns wire names (items, etc.)
    • Confirms model property renaming is NOT broken by the preprocess fix (which only affects spread body parameter wire names)
  • Add changelog entry

…prehensive tests + changelog

Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/f0bedfac-f8d6-42e4-8f6b-6f2b81a2c740

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added lib:http-specs For issues/prs related to the @typespec/http-specs package emitter:client:python Issue for the Python client emitter: @typespec/http-client-python labels Apr 2, 2026
… to avoid duplicated pattern

Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/f0bedfac-f8d6-42e4-8f6b-6f2b81a2c740

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Python emitter using mangled name in requests fix(python): spread body parameters with Mapping protocol names use correct wire name Apr 2, 2026
Copilot AI requested a review from johanste April 2, 2026 01:46
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@10248
npm i https://pkg.pr.new/@typespec/http-specs@10248

commit: 6ab472a

…naming is not broken by fix

Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/4b51c8d8-16ef-4fb8-803e-2b8f52912f2c

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python lib:http-specs For issues/prs related to the @typespec/http-specs package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Python emitter uses mangled name when making requests if parameter name matches method in Mapping protocol

2 participants