Skip to content

[python] fix incorrect padding of wire key name in splatted body method signature#10326

Merged
iscai-msft merged 1 commit intomicrosoft:mainfrom
iscai-msft:python/incorrectWireNamePadding
Apr 9, 2026
Merged

[python] fix incorrect padding of wire key name in splatted body method signature#10326
iscai-msft merged 1 commit intomicrosoft:mainfrom
iscai-msft:python/incorrectWireNamePadding

Conversation

@iscai-msft
Copy link
Copy Markdown
Member

fixes #10247

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Apr 9, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 9, 2026

Open in StackBlitz

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

commit: 2d47431

@iscai-msft
Copy link
Copy Markdown
Member Author

repro generation:

def search(
        self,
        name: str,
        body: Union[JSON, IO[bytes]] = _Unset,
        *,
        scope: str = _Unset,
        items: Optional[list[_models.InputItem]] = None,
        previous_search_id: Optional[str] = None,
        options: Optional[_models.SearchOptions] = None,
        **kwargs: Any
    ) -> _models.SearchResult:
        """search.

        :param name: Required.
        :type name: str
        :param body: Is either a JSON type or a IO[bytes] type. Required.
        :type body: JSON or IO[bytes]
        :keyword scope: Required.
        :paramtype scope: str
        :keyword items: Default value is None.
        :paramtype items: list[~itemstest.models.InputItem]
        :keyword previous_search_id: Default value is None.
        :paramtype previous_search_id: str
        :keyword options: Default value is None.
        :paramtype options: ~itemstest.models.SearchOptions
        :return: SearchResult. The SearchResult is compatible with MutableMapping
        :rtype: ~itemstest.models.SearchResult
        :raises ~corehttp.exceptions.HttpResponseError:
        """
        error_map: MutableMapping = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
        _params = kwargs.pop("params", {}) or {}

        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[_models.SearchResult] = kwargs.pop("cls", None)

        if body is _Unset:
            if scope is _Unset:
                raise TypeError("missing required argument: scope")
            body = {"items": items, "options": options, "previous_search_id": previous_search_id, "scope": scope}
            body = {k: v for k, v in body.items() if v is not None}
        content_type = content_type or "application/json"

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

@typespec/http-client-python - fix ✏️

Fix padding of keys in splatted body parameter method signature

@iscai-msft iscai-msft enabled auto-merge April 9, 2026 17:32
@azure-sdk
Copy link
Copy Markdown
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@iscai-msft iscai-msft added this pull request to the merge queue Apr 9, 2026
Merged via the queue into microsoft:main with commit be99cad Apr 9, 2026
36 checks passed
@iscai-msft iscai-msft deleted the python/incorrectWireNamePadding branch April 9, 2026 18:44
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

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

4 participants