Skip to content

Relax generated Java path length limit - #11983

Merged
Weidong Xu (weidongxu-microsoft) merged 3 commits into
microsoft:mainfrom
weidongxu-microsoft:fix/java-relax-generated-path-length
Sep 16, 2026
Merged

Weidong Xu (weidongxu-microsoft) merged 3 commits into
microsoft:mainfrom
weidongxu-microsoft:fix/java-relax-generated-path-length

Conversation

@weidongxu-microsoft

Copy link
Copy Markdown
Contributor

Summary

Validation

  • npm run build
  • npm run format
  • npm run lint
  • pnpm format
  • mvn test --projects http-client-generator-core --define "test=ClassNameUtilTests" -f .\generator\pom.xml

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
@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client-java
Show changes

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

Allow generated test and sample filenames to use the Azure SDK for Java pipeline's relaxed path-length limit.

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.

🟡 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 where resource-config.json crosses 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.

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.

🔵 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, but JavaPackage.addGraalVmConfig also emits resource-config.json for 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 adding reflect-config.json exceeds 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

@azure-sdk-automation

azure-sdk-automation Bot commented Sep 16, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 277f389f-e041-4191-8637-c3843c839b05

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.

🔵 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.json boundary: the same artifact and assertFalse(directoryName.contains(...)) existed before this PR, when the implementation still budgeted reflect-config.json and the old 38-character reservation, so the test would pass if this change were reverted. Assert the computed resource-config.json path length (or the exact shortened directory) with a case where reflect-config.json fits but resource-config.json is 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

Merged via the queue into microsoft:main with commit 057557b Sep 16, 2026
36 checks passed
@weidongxu-microsoft
Weidong Xu (weidongxu-microsoft) deleted the fix/java-relax-generated-path-length branch September 16, 2026 05:04
Weidong Xu (weidongxu-microsoft) added a commit to Azure/typespec-azure that referenced this pull request Sep 16, 2026
## 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
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