[python] support custom wire names for etags defined with Azure.Core.eTag#10494
Open
iscai-msft wants to merge 6 commits intomicrosoft:mainfrom
Open
[python] support custom wire names for etags defined with Azure.Core.eTag#10494iscai-msft wants to merge 6 commits intomicrosoft:mainfrom
Azure.Core.eTag#10494iscai-msft wants to merge 6 commits intomicrosoft:mainfrom
Conversation
commit: |
Contributor
|
All changed packages have been documented.
Show changes
|
Collaborator
|
You can try these changes here
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes how the Python HTTP client generator handles custom ETag-typed header parameters (e.g. x-ms-if-blob-match, x-ms-if-blob-none-match) by centralizing ETag header classification and ensuring serialization uses the real HTTP header name.
Changes:
- Add a shared
_etag_kind()helper to consistently classify ETag headers asif-matchvsif-none-match. - Preserve the actual header name via
originalWireNameduring preprocessing and use it during header serialization. - Emit an
isEtagflag from the TypeScript emitter so preprocessing can detect custom ETag-typed headers.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/http-client-python/generator/pygen/preprocess/init.py | Centralizes ETag header classification, fixes slot pairing, and preserves originalWireName during header conversion. |
| packages/http-client-python/generator/pygen/codegen/serializers/parameter_serializer.py | Builds ETag header serialization using original_wire_name instead of hard-coded If-Match/If-None-Match. |
| packages/http-client-python/generator/pygen/codegen/models/parameter.py | Adds original_wire_name field to parameter model for downstream serialization. |
| packages/http-client-python/emitter/src/http.ts | Emits isEtag for header parameters by detecting Azure.Core.eTag scalar types. |
| .chronus/changes/python-etagMatchCondition-2026-04-24-18-22-00.md | Changelog entry documenting the fix. |
Custom headers typed as Azure.Core.eTag (e.g. x-ms-blob-if-match, x-ms-source-if-match) now get the same etag/match_condition treatment as standard If-Match/If-None-Match headers. The original wire name is preserved via originalWireName so the correct HTTP header is sent. - Add isEtag flag in emitter for Azure.Core.eTag-typed headers - Add _is_etag_match/_is_etag_none_match helpers in preprocessor - Preserve originalWireName in headers_convert for custom headers - Use originalWireName in serializer for dynamic header name - Use identity-based removal for etag param reordering Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
15ed29c to
f9b7c14
Compare
Move etagRole determination into the emitter's getEtagRole() function. Standard If-Match/If-None-Match headers work with any type. Non-standard headers (e.g. x-ms-blob-if-match) require Azure.Core.eTag type. Simplify preprocess _get_etag_role to just read the etagRole field. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure.Core.eTag
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
msyyc
approved these changes
Apr 28, 2026
Contributor
msyyc
left a comment
There was a problem hiding this comment.
Overall looks good to me. Maybe we could ask TCGC to provide a helper function to help judge etag type in the future.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
_etag_kind()helper — centralizes etag classification usingnone-matchsubstring (stricter than the previousnonecheck which could false-positive on unrelated headers)_etag_kind()to correctly classify custom etag headers before pairingisEtagfrom synthetic clones to prevent re-conversion with wrongoriginalWireName, falls back to standardIf-Match/If-None-Matchwire names_etag_kind()logic