microsoft/semantic-kernel · error · ArgumentException
Topic names registered must be different
Error message
Topic names registered must be different
What it means
Thrown by the ProcessProxyBuilder constructor when the externalTopics list contains duplicate entries. After converting the list to a dictionary, if the dictionary has fewer entries than the list, duplicates were present. Each topic must be unique.
Source
Thrown at dotnet/src/Experimental/Process.Core/ProcessProxyBuilder.cs:31
/// process.
/// </summary>
public sealed class ProcessProxyBuilder : ProcessStepBuilder<KernelProxyStep>
{
/// <summary>
/// Initializes a new instance of the <see cref="ProcessProxyBuilder"/> class.
/// </summary>
internal ProcessProxyBuilder(IReadOnlyList<string> externalTopics, string name, ProcessBuilder? processBuilder)
: base(name, processBuilder)
{
if (externalTopics.Count == 0)
{
throw new ArgumentException("No topic names registered");
}
this._externalTopicUsage = externalTopics.ToDictionary(topic => topic, topic => false);
if (this._externalTopicUsage.Count < externalTopics.Count)
{
throw new ArgumentException("Topic names registered must be different");
}
}
/// <summary>
/// Version of the proxy step, used when saving the state of the step.
/// </summary>
public string Version { get; init; } = "v1";
internal readonly Dictionary<string, bool> _externalTopicUsage;
// For supporting multiple step edges getting linked to the same external topic, current implementation needs to be updated
// to instead have a list of potential edges in case event names in different steps have same name
internal readonly Dictionary<string, KernelProcessProxyEventMetadata> _eventMetadata = [];
internal ProcessFunctionTargetBuilder GetExternalFunctionTargetBuilder()
{
return new ProcessFunctionTargetBuilder(this, functionName: KernelProxyStep.ProcessFunctions.EmitExternalEvent, parameterName: "proxyEvent");
}View on GitHub (pinned to c028a0c7dc)
Solutions
- Deduplicate the topics list before passing it: externalTopics.Distinct().ToList().
- Review the configuration or data source that generates the topics list to eliminate duplicates at the source.
- Add a unit test that asserts topic uniqueness before calling AddProxyStep.
Example fix
// before
var topics = new List<string> { "topic1", "topic1", "topic2" };
process.AddProxyStep("myProxy", topics); // throws
// after
topics = topics.Distinct().ToList();
process.AddProxyStep("myProxy", topics); Defensive patterns
Strategy: validation
Validate before calling
if (externalTopics.Count != externalTopics.Distinct().Count())
throw new ArgumentException("Duplicate topic names detected. All topics must be unique.", nameof(externalTopics));
process.AddProxyStep("myProxy", externalTopics); Prevention
- Deduplicate topic lists with .Distinct() before passing to AddProxyStep.
- Use a HashSet<string> when building topic lists to prevent duplicates.
- Add a unit test asserting topic uniqueness for proxy construction.
When it happens
Trigger: Calling AddProxyStep with an externalTopics list containing duplicate strings, e.g. ["topic1", "topic1", "topic2"]. The ToDictionary call deduplicates, and the count check detects the discrepancy.
Common situations: Building topics from multiple configuration sources that overlap; merging topic lists without deduplication; copy-paste errors that repeat a topic name; dynamic topic generation that can produce duplicates.
Related errors
- No topic names registered
- Entry agent is not defined.
- Invalid AgentId key: '{key}'. Must only contain ASCII charac
- Invalid AgentId type: '{type}'. Must be alphanumeric (a-z, 0
- Last message in chat history was null or whitespace.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/fe57d863bd0df220.
Report an issue: GitHub.