Skip to content

[http-client-java] Report error when clientRequired is set to false#10365

Merged
weidongxu-microsoft merged 8 commits intomainfrom
copilot/fix-client-required-property-issue
Apr 15, 2026
Merged

[http-client-java] Report error when clientRequired is set to false#10365
weidongxu-microsoft merged 8 commits intomainfrom
copilot/fix-client-required-property-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

  • Add new diagnostic client-required-false to lib.ts
  • Move isPropertyRequired from utils.ts to a private method in CodeModelBuilder class in code-model-builder.ts
  • Report error via reportDiagnostic when clientRequired is false
  • Add necessary imports (getClientOptions, DecoratedType) to code-model-builder.ts
  • Update imports in code-model-builder.ts to remove isPropertyRequired from utils
  • Build and test the emitter changes (all 15 tests pass)
  • Add changelog entry
  • Remove clientRequired=false test case from client-option.tsp (it now produces an error)
  • Regenerate ClientOptionClient.java, ClientOptionAsyncClient.java, and ClientRequiredsImpl.java (filter is now required)

…java emitter"

Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/614df4ae-b846-4c9b-9f2e-2f63dffa38e8

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@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 Apr 14, 2026
Copilot AI changed the title [WIP] Fix clientRequired property handling in http-client-java [http-client-java] Report error when clientRequired is set to false Apr 14, 2026
@weidongxu-microsoft
Copy link
Copy Markdown
Contributor

@copilot

please remove this line (as now it is error)
https://github.com/microsoft/typespec/blob/copilot/fix-client-required-property-issue/packages/http-client-java/generator/http-client-generator-test/tsp/client-option.tsp#L29

and run Generate.ps1 to regenerate the code (see instruction on how to run it)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

All changed packages have been documented.

  • @typespec/http-client-java
Show changes

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

Add test case for withRelativeNextLink, FlattenUnknownModel, FlattenReadOnlyModel scenario.

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

Report an error when clientRequired is set to false on a property.

@github-actions
Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client-java
Show changes

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

Report an error when clientRequired is set to false on a property.

…n code

Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/889e1966-4215-477c-8e4f-820993bdb408

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 14, 2026

@copilot

please remove this line (as now it is error)
...

Done in commit f80d2d7. Removed line 29 (clientRequired=false for filter) from client-option.tsp and regenerated the affected files. The filter parameter is now required in the generated Java client — it moved from being an optional nullable field to a required first parameter in post(String filter, ClientRequiredRequest body).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • archive.eclipse.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.14/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/typespec/typespec/packages/http-client-java/generator org.codehaus.plexus.classworlds.launcher.Launcher clean install --no-transfer-progress -T 1C -f ./generator/pom.xml (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.14/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/typespec/typespec/packages/http-client-java/generator org.codehaus.plexus.classworlds.launcher.Launcher clean install --no-transfer-progress -T 1C -f ./generator/pom.xml m/main.tsp --optbash roject-root}/tsp--norc de/node/bin/sh roject-root}/tsp-output/10381595compile (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Comment thread packages/http-client-java/package.json Outdated
@azure-sdk
Copy link
Copy Markdown
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@weidongxu-microsoft weidongxu-microsoft added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit 6dc30bc Apr 15, 2026
30 checks passed
@weidongxu-microsoft weidongxu-microsoft deleted the copilot/fix-client-required-property-issue branch April 15, 2026 03:41
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.

[Bug]: http-client-java, either not allow clientRequired set false to the property, or require property also have a clientDefaultValue

4 participants