{"record":{"id":"f61be9af0b5cf295","repo":"microsoft/semantic-kernel","slug":"error-loading-the-manifest","errorCode":null,"errorMessage":"Error loading the manifest","messagePattern":"Error loading the manifest","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Functions/Functions.OpenApi.Extensions/Extensions/DeclarativeAgentExtensions.cs","lineNumber":59,"sourceCode":"        Verify.NotNullOrWhiteSpace(filePath);\n\n        var loggerFactory = kernel.LoggerFactory;\n        var logger = loggerFactory.CreateLogger(typeof(DeclarativeAgentExtensions)) ?? NullLogger.Instance;\n        using var declarativeAgentFileJsonContents = DocumentLoader.LoadDocumentFromFilePathAsStream(filePath,\n            logger);\n\n        var results = await DCManifestDocument.LoadAsync(declarativeAgentFileJsonContents, new ReaderOptions\n        {\n            ValidationRules = [] // Disable validation rules\n        }).ConfigureAwait(false);\n\n        if (!results.IsValid)\n        {\n            var messages = results.Problems.Select(static p => p.Message).Aggregate(static (a, b) => $\"{a}, {b}\");\n            throw new InvalidOperationException($\"Error loading the manifest: {messages}\");\n        }\n\n        var document = results.Document ?? throw new InvalidOperationException(\"Error loading the manifest\");\n        var manifestDirectory = Path.GetDirectoryName(filePath);\n        document.Instructions = await GetEffectiveInstructionsAsync(manifestDirectory, document.Instructions, logger, cancellationToken).ConfigureAwait(false);\n\n        var agent = new T\n        {\n            Name = document.Name,\n            Instructions = document.Instructions,\n            Kernel = kernel,\n            Arguments = new KernelArguments(promptExecutionSettings ?? new PromptExecutionSettings()\n            {\n                FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(),\n            }),\n            Description = document.Description,\n            LoggerFactory = loggerFactory,\n            Id = string.IsNullOrEmpty(document.Id) ? Guid.NewGuid().ToString() : document.Id!,\n        };\n\n        if (document.Capabilities is { Count: > 0 })","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Functions/Functions.OpenApi.Extensions/Extensions/DeclarativeAgentExtensions.cs#L41-L77","documentation":"Thrown by CreateChatCompletionAgentFromDeclarativeAgentManifestAsync when the loader reports results.IsValid == true but results.Document is null. This is a defensive guard for an inconsistent loader state: the document parsed without reported problems yet no document object was produced. The message carries no interpolated detail because no specific problem was recorded.","triggerScenarios":"An edge case in DCManifestDocument.LoadAsync where the ReadResult is marked valid but the Document property is null - typically a malformed-but-tolerated manifest that the loader silently accepted as valid while producing no bound object. Rare in practice; usually indicates a loader bug or an unusual empty document.","commonSituations":"An essentially empty manifest file (e.g. just '{}' or '---'); a manifest with a recognized root but zero recognizable content; a version mismatch between Microsoft.Plugins.Manifest and the manifest authoring format.","solutions":["Inspect the raw manifest content - if it is empty or trivially structured, add the required top-level fields (name, instructions).","Update the Microsoft.Plugins.Manifest package to match the manifest schema version you are authoring against.","If reproducible with a well-formed manifest, file an issue with the manifest contents; the loader should not return IsValid=true with a null Document.","As a workaround, validate the document is non-empty before calling the SK API."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var info = new FileInfo(filePath);\nif (info.Length == 0) throw new InvalidOperationException(\"Declarative agent manifest is empty.\");","typeGuard":null,"tryCatchPattern":"try { await kernel.CreateChatCompletionAgentFromDeclarativeAgentManifestAsync<T>(path, ct); }\ncatch (InvalidOperationException ex) when (ex.Message == \"Error loading the manifest\")\n{ logger.LogError(ex, \"Loader returned a null document despite IsValid=true.\"); throw; }","preventionTips":["Ensure the manifest has real content (name/instructions).","Keep Microsoft.Plugins.Manifest version aligned with the manifest schema.","Reject empty manifests before loading."],"tags":["declarative-agent","manifest","loader","edge-case"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}