{"record":{"id":"5621edff1544e7e0","repo":"microsoft/semantic-kernel","slug":"plugin-creation-failed-for-pluginname-5621ed","errorCode":null,"errorMessage":"Plugin creation failed for {pluginName}","messagePattern":"Plugin creation failed for (.+?)","errorType":"exception","errorClass":"AggregateException","httpStatus":null,"severity":"error","filePath":"dotnet/samples/Demos/CopilotAgentPlugins/CopilotAgentPluginsDemoSample/DemoCommand.cs","lineNumber":384,"sourceCode":"                { \"https://api.nasa.gov/planetary\", new OpenApiFunctionExecutionParameters(authCallback: GetApiKeyAuthProvider(\"DEMO_KEY\", \"api_key\", false), enableDynamicOperationPayload: false, enablePayloadNamespacing: true)}\n            },\n        };\n\n        try\n        {\n            KernelPlugin plugin =\n            await kernel.ImportPluginFromCopilotAgentPluginAsync(\n                pluginName,\n                GetCopilotAgentManifestPath(pluginName),\n                copilotAgentPluginParameters)\n                .ConfigureAwait(false);\n            AnsiConsole.MarkupLine($\"[bold green] {pluginName} loaded successfully.[/]\");\n        }\n        catch (Exception ex)\n        {\n            AnsiConsole.MarkupLine($\"[red]Failed to load {pluginName}.[/]\");\n            kernel.LoggerFactory.CreateLogger(\"Plugin Creation\").LogError(ex, \"Plugin creation failed. Message: {0}\", ex.Message);\n            throw new AggregateException($\"Plugin creation failed for {pluginName}\", ex);\n        }\n    }\n    #region MagicDoNotLookUnderTheHood\n    private static readonly HashSet<string> s_fieldsToIgnore = new(\n        [\n            \"@odata.type\",\n            \"attachments\",\n            \"allowNewTimeProposals\",\n            \"bccRecipients\",\n            \"bodyPreview\",\n            \"calendar\",\n            \"categories\",\n            \"ccRecipients\",\n            \"changeKey\",\n            \"conversationId\",\n            \"coordinates\",\n            \"conversationIndex\",\n            \"createdDateTime\",","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/samples/Demos/CopilotAgentPlugins/CopilotAgentPluginsDemoSample/DemoCommand.cs#L366-L402","documentation":"The catch block wraps any failure of ImportPluginFromCopilotAgentPluginAsync in an AggregateException with the plugin name. Note: AggregateException wrapping a single inner exception is slightly misleading (AggregateException implies multiple errors); the original cause is in InnerException. The log line is written first, then the throw propagates.","triggerScenarios":"ImportPluginFromCopilotAgentPluginAsync throws — invalid manifest path, malformed Copilot Agent plugin manifest, missing parameters (copilotAgentPluginParameters), network failure fetching the manifest, or schema validation failure inside the importer.","commonSituations":"Plugin name doesn't map to a manifest path, the manifest JSON doesn't match the expected Copilot Agent schema, required runtime arguments were not supplied, or the manifest URL is unreachable.","solutions":["Read ex.InnerException (and the preceding log line) for the real cause before the AggregateException.","Confirm GetCopilotAgentManifestPath(pluginName) returns a reachable, valid manifest path.","Validate the manifest JSON against the Copilot Agent plugin schema.","Supply any required copilotAgentPluginParameters the manifest expects."],"exampleFix":"// before\ncatch (Exception ex)\n{\n    AnsiConsole.MarkupLine($\"[red]Failed to load {pluginName}.[/]\");\n    kernel.LoggerFactory.CreateLogger(\"Plugin Creation\").LogError(ex, \"Plugin creation failed. Message: {0}\", ex.Message);\n    throw new AggregateException($\"Plugin creation failed for {pluginName}\", ex);\n}\n\n// after (preserve true cause; only wrap when you actually aggregate)\ncatch (Exception ex)\n{\n    logger.LogError(ex, \"Plugin creation failed for {Plugin}\", pluginName);\n    throw new InvalidOperationException($\"Plugin creation failed for {pluginName}. See inner exception.\", ex);\n}","handlingStrategy":"try-catch","validationCode":"var manifestPath = GetCopilotAgentManifestPath(pluginName);\nif (!File.Exists(manifestPath) && !Uri.IsWellFormedUriString(manifestPath, UriKind.Absolute))\n    throw new FileNotFoundException($\"Plugin manifest not found: {manifestPath}\", manifestPath);","typeGuard":"static bool ManifestReachable(string path) =>\n    File.Exists(path) || Uri.IsWellFormedUriString(path, UriKind.Absolute);","tryCatchPattern":"try { await kernel.ImportPluginFromCopilotAgentPluginAsync(...); }\ncatch (Exception ex)\n{\n    logger.LogError(ex, \"Plugin creation failed for {Plugin}\", pluginName);\n    throw new InvalidOperationException($\"Plugin creation failed for {pluginName}.\", ex);\n}","preventionTips":["Read InnerException for the true cause — the AggregateException hides it.","Validate the manifest path and JSON schema before importing.","Don't wrap a single exception in AggregateException; preserve the original type."],"tags":["plugins","mcp","copilot-agent","samples"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}