microsoft/semantic-kernel · error · InvalidOperationException

Topic name {topicName} is is already linked to another step

Error message

Topic name {topicName} is is already linked to another step edge

What it means

Thrown by ProcessProxyBuilder.LinkTopicToStepEdgeInfo when the topicName is registered but already marked as used (usedTopic is true). Each topic can only be linked to one step edge in the current implementation. Note the message contains a typo ("is is already").

Source

Thrown at dotnet/src/Experimental/Process.Core/ProcessProxyBuilder.cs:60

    // 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");
    }

    internal void LinkTopicToStepEdgeInfo(string topicName, ProcessStepBuilder sourceStep, ProcessEventData eventData)
    {
        if (!this._externalTopicUsage.TryGetValue(topicName, out bool usedTopic))
        {
            throw new InvalidOperationException($"Topic name {topicName} is not registered as proxy publish event, register first before using");
        }

        if (usedTopic)
        {
            throw new InvalidOperationException($"Topic name {topicName} is is already linked to another step edge");
        }

        this._eventMetadata[eventData.EventName] = new() { EventId = eventData.EventId, TopicName = topicName };
        this._externalTopicUsage[topicName] = true;
    }

    /// <inheritdoc/>
    internal override KernelProcessStepInfo BuildStep(ProcessBuilder processBuilder, KernelProcessStepStateMetadata? stateMetadata = null)
    {
        if (this._externalTopicUsage.All(topic => !topic.Value))
        {
            throw new InvalidOperationException("Proxy step does not have linked steps to it, link step edges to proxy or remove proxy step");
        }

        KernelProcessProxyStateMetadata proxyMetadata = new()
        {
            Name = this.Name,
            Id = this.Id,

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Ensure each topic is linked to exactly one step edge per proxy step.
  2. If multiple steps need to publish to the same logical topic, create separate proxy steps or register additional distinct topic names.
  3. Check the comment in the source: the implementation needs updating to support a list of edges per topic if multi-linking is required.

Example fix

// before
proxy.LinkTopicToStepEdgeInfo("topicA", step1, eventData1);
proxy.LinkTopicToStepEdgeInfo("topicA", step2, eventData2); // throws — topicA already used

// after — use distinct topics for each edge
proxy = process.AddProxyStep("myProxy", externalTopics: new[] { "topicA", "topicB" });
proxy.LinkTopicToStepEdgeInfo("topicA", step1, eventData1);
proxy.LinkTopicToStepEdgeInfo("topicB", step2, eventData2);
Defensive patterns

Strategy: validation

Validate before calling

// Check if topic is already linked before calling LinkTopicToStepEdgeInfo
// (requires internal access to _externalTopicUsage; if not available, track externally)
if (linkedTopics.Contains(topicName))
    throw new InvalidOperationException($"Topic '{topicName}' is already linked to a step edge.");

proxy.LinkTopicToStepEdgeInfo(topicName, sourceStep, eventData);

Prevention

When it happens

Trigger: Calling LinkTopicToStepEdgeInfo twice with the same topicName on the same proxy step; attempting to link two different step edges to the same external topic.

Common situations: Two steps in the process both try to publish to the same external topic; a loop or configuration-driven edge-creation inadvertently links the same topic multiple times; misunderstanding that the current implementation supports only one edge per topic.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/08a70c0778bf0fef. Report an issue: GitHub.