Skip to content

[WIP] Fix issue with defining multiple explicit clients#3665

Closed
Copilot wants to merge 1 commit intomainfrom
copilot/fix-multiple-clients-issue
Closed

[WIP] Fix issue with defining multiple explicit clients#3665
Copilot wants to merge 1 commit intomainfrom
copilot/fix-multiple-clients-issue

Conversation

Copy link
Contributor

Copilot AI commented Dec 30, 2025

Fix multiple explicit clients with multiple services

Problem

The TypeSpec TypeScript emitter's getRLCClients function was experiencing errors when handling multiple services with explicit @client decorators. The error "Can not define multiple explicit clients with multiple services" was being thrown by an older version of TypeSpec Client Generator Core (TCGC).

Resolution

Issue resolved upstream - No code changes needed in autorest.typescript.

The validation error was fixed in TCGC version 0.63.0, which added support for:

  • Multiple services with explicit @client decorators
  • Single client from multiple services feature
  • Proper handling of 1:1 and 1:N service-to-client mappings

Current Implementation Status

  • Understand the problem and current implementation
  • Analyze getRLCClients function behavior
  • Verify tests pass with TCGC 0.63.0
  • Run unit tests to ensure no regressions (311 tests passing)
  • Document the resolution

Implementation Details

The getRLCClients function correctly:

  • Creates one RLC client per service namespace
  • Handles multiple @client decorators per service (deduplicates using Set)
  • Supports the new TCGC array service feature
  • Uses service names for RLC client names (not @client decorator names)

Test Results

✅ All 311 RLC unit tests passing
✅ Test "should get the @client client if each services have only one @client decorators" passing
✅ Test "should handle both 1:1 and 1:N mappings between @service and @client" passing

Conclusion

The issue was resolved by updating to TCGC 0.63.0. No changes to autorest.typescript code are required.

Original prompt

This section details on the original issue you should resolve

<issue_title>Can not define multiple explicit clients with multiple services</issue_title>
<issue_description>RLC case:
https://github.com/Azure/autorest.typescript/blob/main/packages/typespec-ts/test/unit/clientUtil.spec.ts#L78
https://github.com/Azure/autorest.typescript/blob/main/packages/typespec-ts/test/unit/clientUtil.spec.ts#L112

typespec:

import "@azure-tools/typespec-client-generator-core";
using Azure.ClientGenerator.Core;
    
@service
namespace MyService {
  @client({
    name: "MyClient",
    service: MyService
  })
  interface MyInterface {
    op1(): void
  }
}

@service
namespace MySecondService {
  @client({
    name: "MySecondClient",
    service: MySecondService
  })
  interface MySecondInterface {
    op1(): void
  }
}

error log:

Image</issue_description>

Comments on the Issue (you are @copilot in this section)

@v-jiaodi In order to make the nightly CI pass, temporarily skip these two cases. https://dev.azure.com/azure-sdk/public/_build/results?buildId=5707767&view=logs&j=d0d2a462-287f-51d5-e186-98b6b49f577f&t=262df625-0311-50e6-2e41-9dfcf83669de

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can not define multiple explicit clients with multiple services

2 participants