Skip to content

Fix apiVersion clientDefaultValue missing for multi-service operation groups#3887

Open
Copilot wants to merge 4 commits intomainfrom
copilot/fix-api-version-param-issue
Open

Fix apiVersion clientDefaultValue missing for multi-service operation groups#3887
Copilot wants to merge 4 commits intomainfrom
copilot/fix-api-version-param-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 4, 2026

When an operation group contains operations from different services, the clientDefaultValue for apiVersion parameters was incorrectly undefined for all operations. Each operation should get its default from its own service's api version.

Changes

  • internal-utils.ts: Added findServiceForOperation helper and modified updateWithApiVersionInformation to accept an optional operation parameter
  • types.ts: Pass operation to updateWithApiVersionInformation call site
  • structure.test.ts: Added assertions verifying operation-level api version defaults in multi-service scenarios

Before/After

// Multi-service operation group with operations from ServiceA (av1, av2) and ServiceB (bv1, bv2)

// Before: Both operations had undefined clientDefaultValue
aTestMethod.operation.parameters[0].clientDefaultValue // undefined
bTestMethod.operation.parameters[0].clientDefaultValue // undefined

// After: Each operation gets its service's latest version
aTestMethod.operation.parameters[0].clientDefaultValue // "av2"
bTestMethod.operation.parameters[0].clientDefaultValue // "bv2"

Note: Client-level apiVersion parameters for multi-service clients remain undefined by design since there's no single default across services.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: ApiVersion param clientDefaultValue is missing if an operation group contain operations from different services</issue_title>
<issue_description>### Describe the bug

This is specific for multiple services in one client scenario.
When an operation group mixes operations from different services, the clientDefaultValue of the apiVersion parameter of all its operations are missing.

Reproduction

This is the related test typespec: https://github.com/Azure/autorest.typescript/tree/main/packages/typespec-test/test/compute/spec
sdkPackage:
Image

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the TypeSpec repo
  • Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.</issue_description>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 4, 2026 08:54
…groups

When an operation group mixes operations from different services, the
apiVersion parameter at the operation level should still have the
correct clientDefaultValue from the operation's specific service.

The fix modifies updateWithApiVersionInformation to accept an optional
operation parameter. For multi-service clients/operation groups, it now
determines the operation's service and retrieves the api version default
from that service's versions.

Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing clientDefaultValue for apiVersion in operation groups Fix apiVersion clientDefaultValue missing for multi-service operation groups Feb 4, 2026
Copilot AI requested a review from tadelesh February 4, 2026 08:58
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 4, 2026

Open in StackBlitz

npm i https://pkg.pr.new/Azure/typespec-azure/@azure-tools/typespec-client-generator-core@3887

commit: 470183f

Copilot AI requested a review from iscai-msft February 4, 2026 20:02
@iscai-msft iscai-msft marked this pull request as ready for review February 4, 2026 20:04
@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Feb 4, 2026
@azure-sdk
Copy link
Collaborator

All changed packages have been documented.

  • @azure-tools/typespec-client-generator-core
Show changes

@azure-tools/typespec-client-generator-core - fix ✏️

Fixed apiVersion parameter clientDefaultValue missing when an operation group contains operations from different services.

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website

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

Labels

lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ApiVersion param clientDefaultValue is missing if an operation group contain operations from different services

4 participants