Skip to content

fix(http-client-java): handle null LRO error response bodies#11007

Merged
weidongxu-microsoft merged 3 commits into
microsoft:mainfrom
weidongxu-microsoft:fix/http-client-java-lro-empty-body
Jun 18, 2026
Merged

fix(http-client-java): handle null LRO error response bodies#11007
weidongxu-microsoft merged 3 commits into
microsoft:mainfrom
weidongxu-microsoft:fix/http-client-java-lro-empty-body

Conversation

@weidongxu-microsoft

@weidongxu-microsoft weidongxu-microsoft commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

downstream Azure/azure-sdk-for-java#49537

Summary

  • default generated management LRO error response bodies to an empty byte array when the service returns no body
  • add a management template test covering the generated HttpResponseImpl output
  • regenerate the affected management test clients and add a changelog entry

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Jun 17, 2026
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client-java
Show changes

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

Fix null LRO error response body handling in generated management clients.

@azure-sdk-automation

azure-sdk-automation Bot commented Jun 17, 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

This PR updates the Java management (fluent-lite) LRO error handling so that when an LRO error is surfaced without a response body, the generated HttpResponseImpl uses an empty byte array instead of null, preventing NPEs in body accessors and keeping response-body APIs usable.

Changes:

  • Update mgmt FluentServiceClientTemplate to emit responseBody == null ? new byte[0] : ... for LRO error responses.
  • Add a mgmt template unit test asserting the generated HttpResponseImpl uses the empty-byte-array behavior.
  • Regenerate affected mgmt test clients and add a Chronus changelog entry.

Reviewed changes

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

Show a summary per file
File Description
packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/template/FluentServiceClientTemplate.java Changes generated HttpResponseImpl to default responseBody to new byte[0] when null (prevents NPEs in body accessors).
packages/http-client-java/generator/http-client-generator-mgmt/src/test/java/com/microsoft/typespec/http/client/generator/mgmt/template/FluentServiceClientTemplateTests.java Adds a unit test validating the template output contains the new empty-byte-array logic and not the old null logic.
packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ArmVersionedClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armstreamstyleserialization/implementation/ArmResourceProviderManagementClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armresourceprovider/implementation/ArmClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armlegacy/implementation/ArmLegacyClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armcustomization/implementation/ArmCustomizationClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/resources/implementation/ResourcesClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/operationtemplates/implementation/OperationTemplatesClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/nonresource/implementation/NonResourceClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/multiservice/combined/implementation/CombinedImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/methodsubscriptionid/implementation/MethodSubscriptionIdClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/largeheader/implementation/LargeHeaderClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java Regenerated client reflects the new HttpResponseImpl null-body behavior.
.chronus/changes/fix-http-client-java-lro-empty-body-2026-6-17-15-59-00.md Adds a fix changelog entry for the null LRO error body handling change.

@weidongxu-microsoft weidongxu-microsoft marked this pull request as ready for review June 18, 2026 02:28
@weidongxu-microsoft weidongxu-microsoft added this pull request to the merge queue Jun 18, 2026
Merged via the queue into microsoft:main with commit fedfbc9 Jun 18, 2026
34 of 35 checks passed
@weidongxu-microsoft weidongxu-microsoft deleted the fix/http-client-java-lro-empty-body branch June 18, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants