Fix per-client ServiceVersion regression in http-client-java#11286
Merged
XiaofeiCao merged 2 commits intoJul 17, 2026
Merged
Conversation
The ServiceVersion postprocess decides whether a multi-client package gets a single shared ServiceVersion enum or one enum per client, based on whether all clients share the same api-versions. That comparison was changed (PR microsoft#11134, replacing lodash.isEqual with a built-in) to compare ApiVersion values with '==='. Because each client builds its own ApiVersion instances (new ApiVersion()), '===' compares object references and is always false for distinct instances, so every multi-client package incorrectly generated a separate <ClientName>ServiceVersion enum per client. Compare the api-version strings (it.version) instead of the object references, restoring a single shared ServiceVersion when all clients use the same api-versions.
Contributor
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
Adds tsp/multiple-clients-same-version.tsp: a single versioned service split into two clients (AlphaClient, BetaClient) that share the same api-versions, plus the generated Java output. This case previously had no coverage - the only multi-client e2e spec (multiple-services) uses different api-versions per service, where per-client ServiceVersion is correct - which is why the regression went undetected. The generated code contains a single shared MultipleClientsSameVersionServiceVersion enum (referenced by both AlphaClientBuilder and BetaClientBuilder), not a per-client <ClientName>ServiceVersion. With the bug (comparing ApiVersion object references), this spec instead generates AlphaServiceVersion + BetaServiceVersion, so the codegen-diff CI check fails - giving us regression coverage.
XiaofeiCao
marked this pull request as ready for review
July 17, 2026 05:30
XiaofeiCao
requested review from
alzimmermsft,
haolingdong-msft and
weidongxu-microsoft
as code owners
July 17, 2026 05:30
weidongxu-microsoft
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes per-client
ServiceVersionregressionProblem
For a package containing multiple TypeSpec clients, the emitter is supposed to generate a single shared
ServiceVersionenum (named after the package/service) when all clients use the same api-versions, and only fall back to a per-client<ClientName>ServiceVersionwhen the clients genuinely have different api-versions.Recently, multi-client packages started generating a separate
ServiceVersionenum per client even when all clients share the same api-versions, e.g.:azure-search-documents:SearchServiceVersion→SearchIndexServiceVersion,SearchIndexerServiceVersion,KnowledgeBaseRetrievalServiceVersionazure-developer-devcenter:DevCenterServiceVersion→DevCenterServiceVersion,DevBoxesServiceVersion,DeploymentEnvironmentsServiceVersionazure-communication-messages,eventgrid-namespaces, etc.Root cause
In
code-model-builder.ts, the "same api-versions for all clients" check was changed in #11134 (replacinglodash.isEqualwith a built-in comparison):apiVersionsisApiVersion[](objects), notstring[]. Each client builds its ownApiVersioninstances:lodash.isEqualdid a deep value comparison (equal versions → treated as equal), but===compares object references, which is alwaysfalsefor distinct instances. As a resultapiVersionSameForAllClientsbecamefalsefor every multi-client package, triggering the per-clientServiceVersionbranch.Fix
Compare the api-version strings instead of the
ApiVersionobject references:This restores a single shared
ServiceVersionfor multi-client packages whose clients use the same api-versions, while still producing per-clientServiceVersionenums when the api-versions actually differ.Notes