Skip to content

fix(http-client-python): correct etag slot assignment for custom etag-typed headers#10494

Open
iscai-msft wants to merge 3 commits intomicrosoft:mainfrom
iscai-msft:python/etagMatchCondition
Open

fix(http-client-python): correct etag slot assignment for custom etag-typed headers#10494
iscai-msft wants to merge 3 commits intomicrosoft:mainfrom
iscai-msft:python/etagMatchCondition

Conversation

@iscai-msft
Copy link
Copy Markdown
Member

Problem

Custom etag-typed headers (e.g. x-ms-if-blob-match, x-ms-if-blob-none-match) were being assigned to the wrong if-match/if-none-match slot during preprocessing. The slot assignment and the per-parameter conversion used different logic to classify headers, and synthetic partners inherited incorrect wire names.

Changes

  • Added _etag_kind() helper — centralizes etag classification using none-match substring (stricter than the previous none check which could false-positive on unrelated headers)
  • Fixed slot assignment — uses _etag_kind() to correctly classify custom etag headers before pairing
  • Fixed synthetic partner creation — strips isEtag from synthetic clones to prevent re-conversion with wrong originalWireName, falls back to standard If-Match/If-None-Match wire names
  • Unified classification — both slot assignment and per-parameter conversion now use the same _etag_kind() logic

iscai-msft and others added 3 commits April 23, 2026 16:20
Custom conditional headers typed as Azure.Core.eTag (e.g.
x-ms-if-blob-match) now get the same etag/match_condition
parameter conversion as standard If-Match/If-None-Match headers.

Changes:
- Emitter: add isEtag flag to header parameters by checking raw
  TypeSpec type for Azure.Core.eTag scalar
- Preprocess: use isEtag flag to apply etag/match_condition
  conversion for custom conditional headers; preserve original
  wire name so the serializer uses the correct HTTP header
- Parameter model: read originalWireName from YAML
- Serializer: use original wire name for HTTP header instead of
  hardcoded If-Match/If-None-Match

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…aders

- Add _etag_kind() helper to classify etag headers up front using
  'none-match' substring (stricter than 'none') before slot assignment
- Use _etag_kind() for both slot pairing and per-parameter conversion,
  ensuring custom etag headers go to the correct if-match/if-none-match slot
- Strip isEtag from synthetic partner params to prevent them from being
  re-converted with the wrong originalWireName
- Fall back to standard If-Match/If-None-Match wire names for synthetic
  partners since the custom header family name can't be derived

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 24, 2026

Open in StackBlitz

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

commit: 15ed29c

@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 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

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

Fix etag slot assignment for custom etag-typed headers: use stricter none-match heuristic, classify headers before slot pairing, and prevent synthetic partners from inheriting incorrect wire names

@azure-sdk
Copy link
Copy Markdown
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

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.

2 participants