Skip to content

Fix Python wire encoding type regression - #11619

Closed
Libba Lawrence (l0lawrence) wants to merge 3 commits into
microsoft:mainfrom
l0lawrence:l0lawrence-fix-python-wire-encoding
Closed

Fix Python wire encoding type regression#11619
Libba Lawrence (l0lawrence) wants to merge 3 commits into
microsoft:mainfrom
l0lawrence:l0lawrence-fix-python-wire-encoding

Conversation

@l0lawrence

Copy link
Copy Markdown
Member

TCGC now supplies wireType for boolean, integer, and bytes encodings. The Python emitter treated every encoded type with a wire type as unsupported, replacing the client-facing type and regressing existing boolean, numeric, and byte serialization behavior.

This change preserves the normal Python type for supported string, base64, and base64url encodings while retaining the wire-type fallback for custom or unsupported encodings. It also documents that fallback behavior and adds focused emitter coverage for the supported combinations and custom-encoding path.

Validation

  • npm run build
  • npm run format
  • npm run lint -- --emitter
  • npm run test:emitter (13 tests)
  • npm run regenerate (Azure and unbranded)
  • Targeted boolean, numeric, and bytes mock tests (26 tests per flavor)

Preserve supported client-facing types when TCGC supplies wire types for boolean, integer, and byte encodings.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f0bffcdc-e290-4621-980a-834a1e67bdc2
@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 Aug 11, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 54caf83

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

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

Preserve Python boolean, integer, and bytes client types when using supported string, base64, or base64url wire encodings.

@azure-sdk-automation

azure-sdk-automation Bot commented Aug 11, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression in the TypeSpec Python HTTP client emitter where the presence of wireType on encoded built-in scalars caused the emitter to treat otherwise-supported encodings as unsupported, incorrectly changing the client-facing type (notably for booleans, integers, and bytes).

Changes:

  • Preserve the original Python client type for supported encodings (boolean/integer encoded as "string", bytes encoded as "base64"/"base64url") even when wireType is present.
  • Keep the existing fallback behavior: for unknown/custom encodings, expose the wireType-based type while retaining the encode value.
  • Add focused unit tests covering the supported combinations and the custom-encoding fallback, plus a Chronus changelog entry.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/http-client-python/emitter/src/types.ts Updates built-in type emission to preserve supported encoded client types while keeping wire-type fallback for unsupported/custom encodings.
packages/http-client-python/emitter/test/types.test.ts Adds unit tests validating supported encoding preservation and the custom-encoding wire-type fallback path.
.chronus/changes/fix-python-wire-encoding-2026-08-11.md Adds a changelog entry documenting the regression fix for Python wire encoding handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f0bffcdc-e290-4621-980a-834a1e67bdc2
@l0lawrence

Copy link
Copy Markdown
Member Author

Superseded by #11637, which is based on a branch in microsoft/typespec (not a fork) so the emitter-diff check runs. Closing this one.

JoshLove-msft pushed a commit to JoshLove-msft/typespec that referenced this pull request Aug 13, 2026
TCGC now supplies `wireType` for boolean, integer, and bytes encodings.
The Python emitter treated every encoded type with a wire type as
unsupported, replacing the client-facing type and regressing existing
boolean, numeric, and byte serialization behavior.

This change preserves the normal Python type for supported string,
base64, and base64url encodings while retaining the wire-type fallback
for custom or unsupported encodings. It also documents that fallback
behavior and adds focused emitter coverage for the supported
combinations and custom-encoding path.

This PR supersedes microsoft#11619 (which was opened from a fork and therefore
skipped the emitter-diff check).

## Validation

- `npm run build`
- `npm run format`
- `npm run lint -- --emitter`
- `npm run test:emitter` (13 tests)
- `npm run regenerate` (Azure and unbranded)
- Targeted boolean, numeric, and bytes mock tests (26 tests per flavor)

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
Copilot-Session: f0bffcdc-e290-4621-980a-834a1e67bdc2
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.

3 participants