{"record":{"id":"5b5baee4963a4af6","repo":"microsoft/semantic-kernel","slug":"invalid-manifest-file-path","errorCode":null,"errorMessage":"Invalid manifest file path.","messagePattern":"Invalid manifest file path\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Functions/Functions.OpenApi.Extensions/Extensions/DeclarativeAgentExtensions.cs","lineNumber":127,"sourceCode":"        if (string.IsNullOrEmpty(source) ||\n            !source!.StartsWith(\"$[file('\", StringComparison.OrdinalIgnoreCase) ||\n            !source.EndsWith(\"')]\", StringComparison.OrdinalIgnoreCase))\n        {\n            return source;\n        }\n#if NET\n        var filePath = source[8..^3];\n#else\n        var filePath = source.Substring(8, source.Length - 11);\n#endif\n        filePath = GetFullPath(manifestFilePath, filePath);\n        return await DocumentLoader.LoadDocumentFromFilePathAsync(filePath, logger, cancellationToken).ConfigureAwait(false);\n    }\n    private static string GetFullPath(string? manifestDirectory, string relativeOrAbsolutePath)\n    {\n        return !Path.IsPathRooted(relativeOrAbsolutePath) && !relativeOrAbsolutePath.StartsWith(\"http\", StringComparison.OrdinalIgnoreCase)\n            ? string.IsNullOrEmpty(manifestDirectory)\n                ? throw new InvalidOperationException(\"Invalid manifest file path.\")\n                : Path.Combine(manifestDirectory, relativeOrAbsolutePath)\n            : relativeOrAbsolutePath;\n    }\n}\n","sourceCodeStart":109,"sourceCodeEnd":132,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Functions/Functions.OpenApi.Extensions/Extensions/DeclarativeAgentExtensions.cs#L109-L132","documentation":"Thrown by the private GetFullPath helper when a referenced path (an instructions $[file(...)] or an action File) is relative, is not an http URL, AND the manifest directory (Path.GetDirectoryName of the declarative agent file path) is null or empty. Without a base directory there is no anchor to resolve the relative path against, so resolution is refused rather than silently falling back to the CWD.","triggerScenarios":"Loading a declarative agent manifest by a bare filename (e.g. 'agent.yaml') from the current directory, so Path.GetDirectoryName returns an empty string, and the manifest references a relative file (instructions file or action File). Because the directory component is empty, GetFullPath cannot combine the relative reference.","commonSituations":"Passing just 'agent.yaml' instead of an absolute or clearly-rooted path; running the loader where the CWD has no directory prefix; a manifest path constructed by string concatenation that dropped the directory portion.","solutions":["Pass a fully-qualified or clearly rooted path to CreateChatCompletionAgentFromDeclarativeAgentManifestAsync so Path.GetDirectoryName yields a real directory.","Use Path.GetFullPath(manifestPath) before calling so the directory component is always populated.","Ensure any $[file('...')] instructions reference and action File values resolve relative to that directory."],"exampleFix":"// before - bare filename yields an empty directory component\nvar agent = await kernel.CreateChatCompletionAgentFromDeclarativeAgentManifestAsync<ChatCompletionAgent>(\"agent.yaml\");\n\n// after - absolute path gives a real manifest directory\nvar fullPath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, \"Agents\", \"agent.yaml\"));\nvar agent = await kernel.CreateChatCompletionAgentFromDeclarativeAgentManifestAsync<ChatCompletionAgent>(fullPath);","handlingStrategy":"validation","validationCode":"var fullManifestPath = Path.GetFullPath(filePath);\nif (string.IsNullOrEmpty(Path.GetDirectoryName(fullManifestPath)))\n    throw new InvalidOperationException(\"Manifest path must include a directory component.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass Path.GetFullPath(manifestPath) so the directory component is always present.","Use absolute paths anchored to AppContext.BaseDirectory.","Avoid bare filenames that resolve against the CWD."],"tags":["declarative-agent","file-path","relative-path","manifest"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}