{"record":{"id":"e67222b44d499ab5","repo":"iOfficeAI/OfficeCLI","slug":"file-not-found-path","errorCode":null,"errorMessage":"File not found: {path}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/FileSource.cs","lineNumber":86,"sourceCode":"    /// Resolve a source to text lines (for CSV/text data).\n    /// </summary>\n    public static string[] ResolveLines(string source)\n    {\n        var (stream, _) = Resolve(source);\n        using (stream)\n        {\n            using var reader = new StreamReader(stream);\n            var text = reader.ReadToEnd();\n            return text.Split('\\n')\n                .Select(l => l.TrimEnd('\\r'))\n                .ToArray();\n        }\n    }\n\n    private static (MemoryStream, string) ResolveFile(string path)\n    {\n        if (!File.Exists(path))\n            throw new FileNotFoundException($\"File not found: {path}\");\n        return (new MemoryStream(File.ReadAllBytes(path)), Path.GetExtension(path).ToLowerInvariant());\n    }\n\n    private static (MemoryStream, string) ResolveUrl(string url)\n    {\n        // SSRF guard: same connect-time public-IP enforcement as image fetch —\n        // refuse loopback / private / link-local / cloud-metadata targets. See\n        // SsrfGuard. Without this, a caller-supplied data=/model3d=/media= URL\n        // is an SSRF primitive when officecli runs on untrusted input.\n        var handler = SsrfGuard.CreateGuardedHandler(\"file\");\n\n        using var client = new HttpClient(handler, disposeHandler: true) { Timeout = TimeSpan.FromSeconds(30) };\n        client.DefaultRequestHeaders.Add(\"User-Agent\", \"OfficeCLI\");\n\n        var response = client.GetAsync(url).GetAwaiter().GetResult();\n        response.EnsureSuccessStatusCode();\n\n        // Bound memory use: fail fast on an honest oversized Content-Length, then","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/FileSource.cs#L68-L104","documentation":"Thrown by FileSource.ResolveFile when the given filesystem path does not exist (File.Exists returns false). It surfaces as a FileNotFoundException with the offending path so the caller can distinguish a missing-file cause from other resolution failures.","triggerScenarios":"Calling FileSource.Resolve with a plain path (no data:/http(s):// prefix) that does not point to an existing file; relative path resolved against an unexpected working directory.","commonSituations":"Wrong working directory making a relative path unresolvable; path from config pointing to a moved/deleted asset; missing asset in a deployment; case-sensitivity mismatch on Linux.","solutions":["Verify the file exists at the given path (check working directory for relative paths).","Use an absolute path to remove working-directory ambiguity.","On case-sensitive filesystems, confirm the exact casing of the filename."],"exampleFix":"// before\nvar (stream, ext) = FileSource.Resolve(\"assets/logo.png\"); // cwd-relative\n// after\nvar path = Path.Combine(AppContext.BaseDirectory, \"assets\", \"logo.png\");\nvar (stream, ext) = FileSource.Resolve(path);","handlingStrategy":"validation","validationCode":"static (MemoryStream, string) ResolveExistingFile(string path)\n{\n    var full = Path.GetFullPath(path);\n    if (!File.Exists(full))\n        throw new FileNotFoundException($\"File not found: {full}\");\n    return FileSource.Resolve(full);\n}","typeGuard":null,"tryCatchPattern":"try { var r = FileSource.Resolve(path); }\ncatch (FileNotFoundException ex) when (ex.Message.StartsWith(\"File not found\"))\n{ /* report missing asset, offer a picker */ }","preventionTips":["Prefer absolute paths from a known base directory.","On case-sensitive filesystems, verify exact filename casing."],"tags":["file-source","filesystem","file-not-found"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}