{"record":{"id":"cb6633f1faf5e869","repo":"iOfficeAI/OfficeCLI","slug":"path-not-found-path","errorCode":null,"errorMessage":"Path not found: {path}","messagePattern":"Path not found: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.cs","lineNumber":948,"sourceCode":"\n        switch (item.Command.ToLowerInvariant())\n        {\n            // NEWLINE-SEMANTICS-V2: version-stamp items are normally stripped\n            // by BatchCompat.PrepareForReplay; tolerate one that reaches the\n            // executor (plugin NDJSON lines bypass the list-level prepare).\n            case \"meta\":\n                return \"meta\";\n            case \"get\":\n            {\n                var path = item.Path ?? \"/\";\n                var depth = item.Depth ?? 1;\n                var node = handler.Get(path, depth);\n                // Error-typed nodes (e.g. namedrange not found) must surface as\n                // exceptions so --stop-on-error can detect them. Without this,\n                // Get returns a node with Type=\"error\" and a message in Text,\n                // ExecuteBatchItem treats it as success, and stop-on-error never fires.\n                if (node.Type == \"error\")\n                    throw new ArgumentException(node.Text ?? $\"Path not found: {path}\");\n                // Unified envelope: batch get items emit the same\n                // {matches, results: [...]} shape as query items, so callers\n                // can consume batch step output with a single parser.\n                if (format == OutputFormat.Json)\n                    return OfficeCli.Core.OutputFormatter.FormatNodes(new List<DocumentNode> { node }, format);\n                return OfficeCli.Core.OutputFormatter.FormatNode(node, format);\n            }\n            case \"query\":\n            {\n                // `path` is accepted as an alias for `selector` — the generic\n                // field table says \"path (set/remove/get target)\" and users\n                // carry it over to query; ignoring it silently ran an EMPTY\n                // selector, i.e. returned every node as if the predicate\n                // matched (the most dangerous kind of wrong data). Neither\n                // field present is an error, mirroring the required CLI arg.\n                var selector = item.Selector ?? item.Path ?? \"\";\n                if (string.IsNullOrEmpty(selector))\n                    throw new ArgumentException(\"'query' command requires 'selector' field. Example: {\\\"command\\\": \\\"query\\\", \\\"selector\\\": \\\"row[Score>80]\\\"}\");","sourceCodeStart":930,"sourceCodeEnd":966,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.cs#L930-L966","documentation":"Fallback message thrown by ExecuteBatchItem for a batch \"get\" step when handler.Get returned a node whose Type is \"error\" AND whose Text is null. Get returns error-typed nodes (e.g. a named range that does not exist) instead of throwing; the batch executor converts that into an exception so --stop-on-error can detect the failure. This specific string is only used when the node carried no detail text.","triggerScenarios":"{\"command\":\"get\",\"path\":\"/namedrange[DoesNotExist]\"} where the handler returns an error node with no Text; a path referencing a node that was renamed or deleted; a typo in the path.","commonSituations":"Batch generated from a stale document dump where paths no longer exist; renamed styles/named ranges/sheets; wrong file with a different structure; off-by-one in an index expression.","solutions":["Verify the path exists with a query first (`officecli query file \"<selector>\"`).","Regenerate the batch from a fresh dump of the current document.","Fix the path typo or update it to the renamed target.","Confirm you are operating on the intended file/version."],"exampleFix":"// before\n{\"command\":\"get\",\"path\":\"/namedrange[Sales]\"}   // renamed to Revenue\n// after\n{\"command\":\"get\",\"path\":\"/namedrange[Revenue]\"}","handlingStrategy":"validation","validationCode":"// Probe the path with a cheap query before issuing a get step.\nvar exists = handler.Query(path).Any();\nif (!exists) throw new ArgumentException($\"Path not found: {path}\");","typeGuard":null,"tryCatchPattern":"try { ExecuteBatchItem(handler, item, json); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Path not found\"))\n{ /* skip or mark step failed; continue batch */ }","preventionTips":["Verify paths with a query before a get step.","Regenerate batches from a fresh dump after structural edits.","Use --stop-on-error deliberately so these surface."],"tags":["batch","get","path-not-found","validation","officecli"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}