{"record":{"id":"4b5b9b6a888f8098","repo":"iOfficeAI/OfficeCLI","slug":"invalid-value","errorCode":"invalid_value","errorMessage":"--compact is a plain-text line format; drop --json (or drop --compact for the JSON tree).","messagePattern":"--compact is a plain-text line format; drop --json \\(or drop --compact for the JSON tree\\)\\.","errorType":"error_code","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.GetQuery.cs","lineNumber":193,"sourceCode":"        var queryFieldsOpt = new Option<string?>(\"--fields\") { Description = \"Comma-separated Format keys appended as extra k=v columns in --compact output (e.g. x,y,width)\" };\n\n        var queryCommand = new Command(\"query\", \"Query document elements with CSS-like selectors\");\n        queryCommand.Add(queryFileArg);\n        queryCommand.Add(selectorArg);\n        queryCommand.Add(jsonOption);\n        queryCommand.Add(queryFindOpt);\n        queryCommand.Add(queryCompactOpt);\n        queryCommand.Add(queryFieldsOpt);\n\n        queryCommand.SetAction(result => { var json = result.GetValue(jsonOption); return SafeRun(() =>\n        {\n            var file = result.GetValue(queryFileArg)!;\n            var selector = MsysPathHint.Restore(result.GetValue(selectorArg)!)!;\n            var textFilter = result.GetValue(queryFindOpt);\n            var compact = result.GetValue(queryCompactOpt);\n            var fields = result.GetValue(queryFieldsOpt);\n            if (compact && json)\n                throw new OfficeCli.Core.CliException(\"--compact is a plain-text line format; drop --json (or drop --compact for the JSON tree).\") { Code = \"invalid_value\" };\n\n            if (TryResident(file.FullName, req =>\n            {\n                req.Command = \"query\";\n                req.Json = json;\n                req.Args[\"selector\"] = selector;\n                if (textFilter != null) req.Args[\"find\"] = textFilter;\n                if (compact) req.Args[\"compact\"] = \"true\";\n                if (fields != null) req.Args[\"fields\"] = fields;\n            }, json) is {} rc) return rc;\n\n            var format = json ? OutputFormat.Json : OutputFormat.Text;\n\n            using var handler = DocumentHandlerFactory.Open(file.FullName);\n            // CONSISTENCY(cell-selector-alias): the Excel cell selector accepts short\n            // aliases (bold -> font.bold, size -> font.size, ...). FilterSelector\n            // applies the same normalization, runs the boolean and/or engine, and\n            // routes a pure-AND (flat) selector through the exact legacy path.","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.GetQuery.cs#L175-L211","documentation":"Thrown by the `query` command when both --compact and --json are supplied. --compact emits a plain-text, one-line-per-match tabular format incompatible with the JSON tree shape; the guard at line 192-193 rejects the combination with code `invalid_value` rather than producing ambiguous output.","triggerScenarios":"`officecli query file.docx 'p' --compact --json`. compact && json is true triggers the throw.","commonSituations":"A script shares a flags object between query and get and inherits both; a user wants machine-readable output and adds --json on top of --compact; an agent stacks output-format flags assuming they compose.","solutions":["For machine-readable output, drop --compact and keep --json (returns the JSON tree).","For compact tabular output, drop --json and keep --compact (plain text lines).","Pick one output mode per invocation."],"exampleFix":"# before\nofficecli query file.docx 'p' --compact --json\n\n# after\nofficecli query file.docx 'p' --json","handlingStrategy":"validation","validationCode":"// Enforce mutual exclusivity of --compact and --json before invoking query.\nif (compact && json) throw new ArgumentException(\"use --compact OR --json, not both\");","typeGuard":"// Guard: exactly one output mode for query.\nstatic bool SingleQueryMode(bool compact, bool json) => !(compact && json);","tryCatchPattern":null,"preventionTips":["Derive the output mode from a single enum in your wrapper, never two independent booleans.","Default pipelines to --json; reserve --compact for human-facing terminal output."],"tags":["argument-validation","query","format","mutual-exclusivity"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}