Skip to content

auto-merge-service-conflict

Id
@azure-tools/typespec-client-generator-core/auto-merge-service-conflict

Severity: error

This diagnostic is issued when a parent client uses autoMergeService and a nested client also specifies its own service configuration.

  • Area: Multi-service client hierarchy. Blocks an auto-merged parent client from also containing a nested client with its own explicit service binding.
  • Not affected: The underlying service namespaces and routes remain valid independently.
@service
namespace ServiceA {
@route("/aTest")
op opA(): void;
}
@service
namespace ServiceB {
@route("/bTest")
op opB(): void;
}
@client({
name: "ParentClient",
service: [ServiceA, ServiceB],
autoMergeService: true,
})
namespace ParentClient {
@client({
name: "ChildClient",
service: ServiceA, // child service conflicts with the parent's `autoMergeService`
})
namespace Child {
}
}

TCGC reports:

Auto-merging service client must be empty.

Leave the nested client’s service option unset so it inherits from the parent, or remove the parent autoMergeService setup.

@service
namespace ServiceA {
@route("/aTest")
op opA(): void;
}
@service
namespace ServiceB {
@route("/bTest")
op opB(): void;
}
@client({
name: "ParentClient",
service: [ServiceA, ServiceB],
autoMergeService: true,
})
namespace ParentClient {
@client({
name: "ChildClient",
})
namespace Child {
}
}