microsoft/semantic-kernel · error · InvalidOperationException

A message targeting function '{message.FunctionName}' has re

Error message

A message targeting function '{message.FunctionName}' has resulted in a function named '{invocableFunctions.First()}' becoming invocable. Are the function names configured correctly?

What it means

After AssignStepFunctionParameterValues adds message values to the inputs, HandleMessageAsync computes which functions have all required parameters satisfied (invocableFunctions). It expects the function named in message.FunctionName to be among them. If a different function became invocable instead, this InvalidOperationException is thrown, signalling a mismatch between the edge configuration and the step's actual function signatures.

Source

Thrown at dotnet/src/Experimental/Process.Runtime.Dapr/Actors/StepActor.cs:290

        this._logger?.LogDebug("Received message from '{SourceId}' targeting function '{FunctionName}' and parameters '{Parameters}'.", message.SourceId, message.FunctionName, messageLogParameters);

        // Add the message values to the inputs for the function
        this.AssignStepFunctionParameterValues(message);

        // If we're still waiting for inputs on all of our functions then don't do anything.
        List<string> invocableFunctions = this._inputs.Where(i => i.Value != null && i.Value.All(v => v.Value != null)).Select(i => i.Key).ToList();
        var missingKeys = this._inputs.Where(i => i.Value is null || i.Value.Any(v => v.Value is null));

        if (invocableFunctions.Count == 0)
        {
            string missingKeysLog() => string.Join(", ", missingKeys.Select(k => $"{k.Key}: {string.Join(", ", k.Value?.Where(v => v.Value == null).Select(v => v.Key) ?? [])}"));
            this._logger?.LogInformation("No invocable functions, missing keys: {MissingKeys}", missingKeysLog());
            return;
        }

        // A message can only target one function and should not result in a different function being invoked.
        var targetFunction = invocableFunctions.FirstOrDefault((name) => name == message.FunctionName) ??
            throw new InvalidOperationException($"A message targeting function '{message.FunctionName}' has resulted in a function named '{invocableFunctions.First()}' becoming invocable. Are the function names configured correctly?").Log(this._logger);

        this._logger?.LogInformation("Step with Id `{StepId}` received all required input for function [{TargetFunction}] and is executing.", this.Name, targetFunction);

        // Concat all the inputs and run the function
        KernelArguments arguments = new(this._inputs[targetFunction]!);
        if (!this._functions.TryGetValue(targetFunction, out KernelFunction? function) || function == null)
        {
            throw new InvalidOperationException($"Function {targetFunction} not found in plugin {this.Name}").Log(this._logger);
        }

        // Invoke the function, catching all exceptions that it may throw, and then post the appropriate event.
#pragma warning disable CA1031 // Do not catch general exception types
        try
        {
            this?._logger?.LogInformation("Invoking function {FunctionName} with arguments {Arguments}", targetFunction, arguments);
            FunctionResult invokeResult = await this.InvokeFunction(function, this._kernel, arguments).ConfigureAwait(false);

            this?.Logger?.LogInformation("Function {FunctionName} returned {Result}", targetFunction, invokeResult);

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Verify that the edge's KernelProcessFunctionTarget.FunctionName exactly matches a [KernelFunction] name on the destination step class.
  2. Check that the KernelProcessFunctionTarget.ParameterName matches the actual method parameter name on the [KernelFunction].
  3. Rebuild the process graph if the step class's function signatures have changed (renamed methods, added/removed parameters).
Defensive patterns

Strategy: validation

Validate before calling

// Before deploying, validate that edge function names match step [KernelFunction] names:
var stepType = typeof(MyStep);
var functionNames = stepType.GetMethods()
    .Where(m => m.GetCustomAttribute<KernelFunctionAttribute>() != null)
    .Select(m => m.Name)
    .ToHashSet();

foreach (var edge in processBuilder.Build().Edges)
{
    foreach (var e in edge.Value)
    {
        if (e.OutputTarget is KernelProcessFunctionTarget ft && !functionNames.Contains(ft.FunctionName))
        {
            throw new InvalidOperationException($"Edge targets function '{ft.FunctionName}' which does not exist on {stepType.Name}.");
        }
    }
}

Type guard

static bool IsValidFunctionName(Type stepType, string functionName)
{
    return stepType.GetMethods()
        .Any(m => m.GetCustomAttribute<KernelFunctionAttribute>() != null && m.Name == functionName);
}

Try / catch

try
{
    await stepActor.ProcessIncomingMessagesAsync();
}
catch (InvalidOperationException ex) when (ex.Message.Contains("function names configured correctly"))
{
    logger.LogError("Function name mismatch in edge configuration. Verify [KernelFunction] names match edge targets.");
}

Prevention

When it happens

Trigger: A message targeting function 'A' delivers parameter values that cause function 'B' to have all inputs satisfied. This means the edge that produced the message references a function name or parameter mapping that does not match the step's [KernelFunction] definitions.

Common situations: A step has multiple [KernelFunction] methods and the edge's KernelProcessFunctionTarget.FunctionName is misspelled or refers to a removed function. Parameter names in the function target don't match the actual method parameters, so values accumulate under the wrong function. A process graph was built against an older version of the step class.

Related errors


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