fix(http-client-java): gate XML serializer to azure-v1 data-plane and skip raw bytes payloads - #11329
Merged
weidongxu-microsoft merged 4 commits intoJul 22, 2026
Conversation
… skip raw bytes payloads XML ObjectSerializer (SERIALIZER) was emitted whenever an operation had an XML content-type, even for raw byte[]/BinaryData payloads and non-data-plane clients. For raw XML bytes responses this referenced a non-generated XmlSerializerProviders helper, causing a build break. Gate SERIALIZER emission on isAzureV1() && isDataPlaneClient() and on the payload being an actual model (not byte[]/BinaryData/Base64Url), inspecting the convenience method model body types rather than the protocol method's BinaryData. Adds a tsp/xml-bytes-verify.tsp verification case and a reflection-based XmlBytesVerifyTests asserting no SERIALIZER field is generated for raw bytes payloads. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9caec63c-f4be-44fe-9f9c-4f2eda60ff60
Contributor
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
Rename the generated static XML ObjectSerializer field from SERIALIZER to XML_SERIALIZER for clarity and regenerate the java test baselines. Includes full Generate.ps1 regeneration updates for payload/xml and updates reflection assertions in XmlBytesVerifyTests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9caec63c-f4be-44fe-9f9c-4f2eda60ff60
…apping Remove duplicated response-body unwrapping logic from sync/async convenience templates and reuse ConvenienceMethodTemplateBase#getConvenienceResponseBodyType. Keep sync-specific ResponseBase detection helper for response construction only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9caec63c-f4be-44fe-9f9c-4f2eda60ff60
…wrapping Add unit tests for ConvenienceMethodTemplateBase#getConvenienceResponseBodyType covering mono/response, paged flux, response base, nested paged response base, and non-generic passthrough cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9caec63c-f4be-44fe-9f9c-4f2eda60ff60
weidongxu-microsoft
marked this pull request as ready for review
July 22, 2026 00:29
weidongxu-microsoft
requested review from
XiaofeiCao,
alzimmermsft and
haolingdong-msft
as code owners
July 22, 2026 00:29
Contributor
Author
XiaofeiCao
approved these changes
Jul 22, 2026
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.
Fix XML serializer gating for byte[] payloads
Problem
A recent change (support XML serialization in the http-client-java generator) emitted a static XML
ObjectSerializer SERIALIZERfield whenever an operation had an XML content-type. This was wrong in two cases:byte[]/BinaryDatapayloads (e.g. an operation returning a raw XML document asbytes, likeazure-analytics-planetarycomputer'sgetWmtsCapabilities). Here theSERIALIZERreferenced anXmlSerializerProvidershelper that is only generated for models actually used in XML, so the generated code failed to compile.azure-v1data-plane clients. XMLObjectSerializerhandling only applies to theazure-core(v1) data-plane flavor.Fix
SERIALIZERemission onisAzureV1() && isDataPlaneClient().ObjectSerializerwhen the payload is an actual model, i.e. notbyte[]/BinaryData/Base64Url.Mono/Flux/Response/ResponseBase/PagedIterable/PagedFlux/PagedResponseBase) instead of the protocol method'sBinaryDatatype.Verification
tsp/xml-bytes-verify.tspcase (data-plane azure-v1 op returningbyteswithapplication/xml) generates committed source undertsptest/xmlbytesverify.XmlBytesVerifyTestsasserts the generated clients declare no staticSERIALIZERfield for raw bytes payloads, with a positive control onpayload.xml.SimpleModelValueClient.payload/xmlproduces identical output (SERIALIZERcount unchanged at 312), confirming real XML model clients are unaffected.Ref: Azure/azure-sdk-for-java#49877