{"record":{"id":"44b8d575d5565e0e","repo":"iOfficeAI/OfficeCLI","slug":"set-command-requires-path-field-example-co","errorCode":null,"errorMessage":"'set' command requires 'path' field. Example: {\"command\": \"set\", \"path\": \"/slide[1]\", \"props\": {\"bold\": \"true\"}}","messagePattern":"'set' command requires 'path' field\\. Example: (.+?)\\}","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.cs","lineNumber":982,"sourceCode":"                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]\\\"}\");\n                Func<string, string>? keyResolver =\n                    handler is OfficeCli.Handlers.ExcelHandler\n                    && OfficeCli.Handlers.ExcelHandler.SelectorTargetsCells(selector)\n                        ? OfficeCli.Handlers.ExcelHandler.ResolveCellAttributeAlias : null;\n                var (results, warnings) = OfficeCli.Core.AttributeFilter.FilterSelector(selector, handler.Query, keyResolver);\n                if (item.Text is { } textFilter && !string.IsNullOrEmpty(textFilter))\n                    // MatchesTextFilter (not plain Contains) so a batch query\n                    // text filter honours r\"regex\" like the CLI and resident do.\n                    results = results.Where(n => n.Text != null && OfficeCli.Core.AttributeFilter.MatchesTextFilter(n.Text, textFilter)).ToList();\n                foreach (var w in warnings) Console.Error.WriteLine(w.Message);\n                return OfficeCli.Core.OutputFormatter.FormatNodes(results, format);\n            }\n            case \"set\":\n            {\n                if (string.IsNullOrEmpty(item.Path))\n                    throw new ArgumentException(\"'set' command requires 'path' field. Example: {\\\"command\\\": \\\"set\\\", \\\"path\\\": \\\"/slide[1]\\\", \\\"props\\\": {\\\"bold\\\": \\\"true\\\"}}\");\n                // Match standalone `set` rejection of empty/missing props — a\n                // batch step with no props is a no-op that previously reported\n                // success, hiding caller mistakes (forgotten props field,\n                // misspelled key promoted to root, etc.).\n                if (props.Count == 0)\n                    throw new ArgumentException(\"'set' command requires 'props' field with at least one key=value. Got empty/missing props.\");\n                var path = item.Path;\n                OfficeCli.Core.MutationSelectorGuard.EnsureScoped(path, \"set\");\n                // Shared core: apply + prop-autocorrect + categorise. Identical\n                // across CLI / batch / MCP / resident; only the output below is\n                // batch-specific.\n                var (applied, unsupported, autoCorrected) = ApplySetWithCorrection(handler, path, props);\n                var parts = new List<string>();\n                if (autoCorrected.Count > 0)\n                    parts.Add(\"Auto-corrected: \" + string.Join(\", \", autoCorrected.Select(ac => $\"{ac.Original}→{ac.Corrected}\")));\n                if (applied.Count > 0)\n                {\n                    var msg = $\"Updated {path}: {string.Join(\", \", applied.Select(kv => $\"{kv.Key}={kv.Value}\"))}\";","sourceCodeStart":964,"sourceCodeEnd":1000,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.cs#L964-L1000","documentation":"Thrown by ExecuteBatchItem for a batch \"set\" step when item.Path is null or empty. Set must target a specific node; there is no implicit root target. This mirrors the standalone set command's required path argument.","triggerScenarios":"{\"command\":\"set\",\"props\":{\"bold\":\"true\"}} (no path); a set step where the path variable was null/empty; a templating bug that dropped the path field.","commonSituations":"Forgotten path field in a hand-written batch; a path computed from a null/empty variable; a copy-paste that lost the path line; a generator that emitted props but not path.","solutions":["Add the target path: {\"command\":\"set\",\"path\":\"/slide[1]\",\"props\":{\"bold\":\"true\"}}.","Ensure the path variable is non-null and non-empty before emitting the step.","Validate every set step has a non-empty path before batch submission.","If targeting the root, use an explicit root path accepted by the handler."],"exampleFix":"// before\n{\"command\":\"set\",\"props\":{\"bold\":\"true\"}}\n// after\n{\"command\":\"set\",\"path\":\"/slide[1]\",\"props\":{\"bold\":\"true\"}}","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(item.Path))\n    throw new ArgumentException(\"'set' requires a non-empty 'path'\");","typeGuard":"static bool IsValidSetItem(BatchItem i)\n    => !string.IsNullOrEmpty(i.Path) && (i.Props?.Count ?? 0) > 0;","tryCatchPattern":null,"preventionTips":["Require a non-empty path on every set step.","Validate the batch item before submission.","Guard against null/empty path variables in generators."],"tags":["batch","set","validation","officecli"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}