Relax generated Java path length limit - #11983
Weidong Xu (weidongxu-microsoft) merged 3 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 277f389f-e041-4191-8637-c3843c839b05
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 277f389f-e041-4191-8637-c3843c839b05
|
All changed packages have been documented.
Show changes
|
There was a problem hiding this comment.
🟡 Changes recommended
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR relaxes generated Java path-length calculations to reserve 30 characters for the checkout root, matching Azure SDK for Java pipelines.
Changes:
- Updates class-name truncation limits.
- Applies the relaxed reservation to GraalVM paths.
- Adjusts boundary tests and adds a Chronus fix entry.
File summaries
| File | Description |
|---|---|
| packages/http-client-java/generator/http-client-generator-core/src/test/java/com/microsoft/typespec/http/client/generator/core/util/ClassNameUtilTests.java | Updated as part of this pull request. |
| packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ClassNameUtil.java | Updated as part of this pull request. |
| .chronus/changes/fix-java-relax-generated-path-length-2026-09-16.md | Updated as part of this pull request. |
Review details
Suppressed comments (3)
packages/http-client-java/generator/http-client-generator-core/src/test/java/com/microsoft/typespec/http/client/generator/core/util/ClassNameUtilTests.java:58
- This case is exactly 230 characters, not over 230: the implementation now checks
> 230, so the assertion intentionally keeps the unshortened path. Please update the comment to describe the exact boundary being tested.
// directory and full filename fit the relaxed limits
packages/http-client-java/generator/http-client-generator-core/src/test/java/com/microsoft/typespec/http/client/generator/core/util/ClassNameUtilTests.java:61
- This boundary test only checks whether the long directory prefix is retained; it does not exercise the longest file emitted by
JavaPackage(resource-config.json) at the new 230-character limit. Add a case whereresource-config.jsoncrosses the limit while the other config files fit, so a regression in this path calculation cannot pass unnoticed.
Assertions.assertTrue(directoryName.contains("azure-resourcemanager-"));
packages/http-client-java/generator/http-client-generator-core/src/test/java/com/microsoft/typespec/http/client/generator/core/util/ClassNameUtilTests.java:53
- With the new thresholds, this input does not exceed the 218-character directory limit; it is shortened because the full path exceeds the 230-character file limit. The comment therefore documents the wrong condition and makes the boundary test misleading. Please describe the full-path condition instead.
// directory length over 218
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🔵 Needs a closer look
One or more issues must be addressed before approval.
Review details
Suppressed comments (2)
packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ClassNameUtil.java:76
- This check uses only
reflect-config.json, butJavaPackage.addGraalVmConfigalso emitsresource-config.jsonfor non-fluent clients, and that filename is one character longer. At the exact relaxed boundary, the reflect path can fit while the resource path exceeds the 260-character Windows limit; compare against the longest emitted filename and add a boundary regression test.
if (parentDirectoryLength + metaInfPath.length() > (MAX_DIRECTORY_LENGTH - BASE_PATH_LENGTH)
|| parentDirectoryLength + metaInfPath.length() + fileNameLength > (MAX_PATH_LENGTH - BASE_PATH_LENGTH)) {
packages/http-client-java/generator/http-client-generator-core/src/test/java/com/microsoft/typespec/http/client/generator/core/util/ClassNameUtilTests.java:55
- For this input,
parentDirectoryLength + metaInfPath.length()is 216, not greater than the new 218 directory limit; it falls back only because addingreflect-config.jsonexceeds 230. As a result, the updated test does not exercise the directory-limit branch changed here; make this artifact at least three characters longer or add a separate case over 218.
// directory length over 218
String directoryName = ClassNameUtil.getDirectoryNameForGraalVmConfig("com.azure.resourcemanager",
"azure-resourcemanager-" + KUBERNETES_CONFIGURATION + "-extensiontypes");
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
You can try these changes here
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 277f389f-e041-4191-8637-c3843c839b05
There was a problem hiding this comment.
🔵 Needs a closer look
One or more issues must be addressed before approval.
Review details
Suppressed comments (1)
packages/http-client-java/generator/http-client-generator-core/src/test/java/com/microsoft/typespec/http/client/generator/core/util/ClassNameUtilTests.java:61
- This assertion does not cover the new
resource-config.jsonboundary: the same artifact andassertFalse(directoryName.contains(...))existed before this PR, when the implementation still budgetedreflect-config.jsonand the old 38-character reservation, so the test would pass if this change were reverted. Assert the computedresource-config.jsonpath length (or the exact shortened directory) with a case wherereflect-config.jsonfits butresource-config.jsonis one character over, so a regression to the shorter filename budget fails.
// reflect-config.json fits exactly at 230, but resource-config.json exceeds the limit by one
directoryName = ClassNameUtil.getDirectoryNameForGraalVmConfig("com.azure.resourcemanager",
"azure-resourcemanager-" + "recovery" + "services" + "data" + "replication");
Assertions.assertFalse(directoryName.contains("azure-resourcemanager-"));
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
## Summary - cherry-pick the TypeSpec Java 0.47.0 sync and publish commits onto the September release branch - update the TypeSpec core pin to `057557b68` - include fixes from microsoft/typespec#11967, microsoft/typespec#11982, and microsoft/typespec#11983 ## Validation - `pnpm format` - `pnpm lint` - `pnpm -r --filter "@azure-tools/typespec-java..." build` - `pnpm regenerate -- --parallelization 4 --skip-build` - `pnpm test` - `pnpm test:java:e2e` --------- Copilot-Session: 6c2c4c77-2a95-4598-bef6-898cd8b31623 Copilot-Session: bbb8f8a7-8cb7-4e00-8c51-872dee15fcc9
Summary
Validation
npm run buildnpm run formatnpm run lintpnpm formatmvn test --projects http-client-generator-core --define "test=ClassNameUtilTests" -f .\generator\pom.xml