{"record":{"id":"8ee043b87c2b18c1","repo":"microsoft/semantic-kernel","slug":"function-targetfunction-not-found-in-plugin-thi-8ee043","errorCode":null,"errorMessage":"Function {targetFunction} not found in plugin {this.Name}","messagePattern":"Function (.+?) not found in plugin (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Runtime.Dapr/Actors/StepActor.cs","lineNumber":298,"sourceCode":"\n        if (invocableFunctions.Count == 0)\n        {\n            string missingKeysLog() => string.Join(\", \", missingKeys.Select(k => $\"{k.Key}: {string.Join(\", \", k.Value?.Where(v => v.Value == null).Select(v => v.Key) ?? [])}\"));\n            this._logger?.LogInformation(\"No invocable functions, missing keys: {MissingKeys}\", missingKeysLog());\n            return;\n        }\n\n        // A message can only target one function and should not result in a different function being invoked.\n        var targetFunction = invocableFunctions.FirstOrDefault((name) => name == message.FunctionName) ??\n            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);\n\n        this._logger?.LogInformation(\"Step with Id `{StepId}` received all required input for function [{TargetFunction}] and is executing.\", this.Name, targetFunction);\n\n        // Concat all the inputs and run the function\n        KernelArguments arguments = new(this._inputs[targetFunction]!);\n        if (!this._functions.TryGetValue(targetFunction, out KernelFunction? function) || function == null)\n        {\n            throw new InvalidOperationException($\"Function {targetFunction} not found in plugin {this.Name}\").Log(this._logger);\n        }\n\n        // Invoke the function, catching all exceptions that it may throw, and then post the appropriate event.\n#pragma warning disable CA1031 // Do not catch general exception types\n        try\n        {\n            this?._logger?.LogInformation(\"Invoking function {FunctionName} with arguments {Arguments}\", targetFunction, arguments);\n            FunctionResult invokeResult = await this.InvokeFunction(function, this._kernel, arguments).ConfigureAwait(false);\n\n            this?.Logger?.LogInformation(\"Function {FunctionName} returned {Result}\", targetFunction, invokeResult);\n\n            // Persist the state after the function has been executed\n            var stateJson = JsonSerializer.Serialize(this._stepState, this._stepStateType!);\n            await this.StateManager.SetStateAsync(ActorStateKeys.StepStateJson, stateJson).ConfigureAwait(false);\n            await this.StateManager.SaveStateAsync().ConfigureAwait(false);\n\n            await this.EmitEventAsync(\n                ProcessEvent.Create(","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Runtime.Dapr/Actors/StepActor.cs#L280-L316","documentation":"HandleMessageAsync looks up the invocable function name in the _functions dictionary. If the function name from _inputs (which should mirror _functions) is not found in _functions, this InvalidOperationException is thrown. This indicates an inconsistency between the input-channel map and the loaded kernel functions.","triggerScenarios":"The _inputs dictionary contains a key for a function that does not exist in _functions. Since GenerateInitialInputs derives _inputs from _functions via FindInputChannels, this mismatch should not occur under normal operation — it points to a corrupted state or a race condition during activation.","commonSituations":"A bug in FindInputChannels or GenerateInitialInputs that creates input entries for functions not in the plugin. Concurrent modification of _inputs or _functions during message processing. A subclass override of GenerateInitialInputs that introduces inconsistent keys.","solutions":["Verify that GenerateInitialInputs (or its override) only returns function names that exist in the _functions dictionary.","If overriding GenerateInitialInputs or AssignStepFunctionParameterValues in a subclass, ensure consistency between input keys and loaded functions.","Inspect the step's [KernelFunction] methods and the KernelPlugin created from the step instance to confirm all expected functions are loaded."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// This is an internal consistency error. Verify that GenerateInitialInputs produces keys\n// that match the loaded kernel functions:\nvar plugin = KernelPluginFactory.CreateFromObject(stepInstance);\nvar functionNames = plugin.Select(f => f.Name).ToHashSet();\nvar inputKeys = stepInstance.GenerateInitialInputs().Keys.ToHashSet();\nif (!inputKeys.IsSubsetOf(functionNames))\n{\n    throw new InvalidOperationException(\"Input channel keys do not match loaded functions.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await stepActor.ProcessIncomingMessagesAsync();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"not found in plugin\"))\n{\n    logger.LogError(\"Function name inconsistency between input channels and loaded kernel functions. This is likely an internal bug or a subclass override issue.\");\n}","preventionTips":["If overriding GenerateInitialInputs or AssignStepFunctionParameterValues, maintain key consistency with _functions.","Do not manually modify _inputs or _functions dictionaries from external code.","Report this error to the library maintainers if it occurs without custom overrides."],"tags":["dapr","process-runtime","function-resolution","internal-error","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}