{"record":{"id":"38b3e8725a228535","repo":"pbakaus/impeccable","slug":"error-38b3e8","errorCode":null,"errorMessage":"{}\n","messagePattern":"\\{\\}\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/context/src/context_cli.rs","lineNumber":580,"sourceCode":"            if content.is_empty() {\n                None\n            } else {\n                Some((n.to_string(), content))\n            }\n        })\n        .collect()\n}\n\n// ─── cli ───────────────────────────────────────────────────────────────────\n\npub fn run(args: &[String], io: &mut Io) -> i32 {\n    let cwd = io.cwd.to_string_lossy().into_owned();\n    let env = io.env.clone();\n    let provider = crate::provider::detect(&env, &cwd);\n    let options = match parse_target_options(args, true) {\n        Ok(o) => o,\n        Err(msg) => {\n            io.err(&format!(\"{}\\n\", msg));\n            return 1;\n        }\n    };\n    let target_provided = has_target_option(&options);\n    // #706: resolve `--target` once, so a bare workspace name does not walk\n    // the candidates twice and loadContext sees the resolved path.\n    let resolved_target_path = if target_provided {\n        Some(resolve_target_path(\n            &cwd,\n            options.target_path.as_deref().unwrap(),\n            &env,\n        ))\n    } else {\n        None\n    };\n    let target_exists = resolved_target_path.as_deref().map(exists);\n    if let Some(sel) = resolve_target_selection(&cwd, &options, &env) {\n        io.out(&format!(\"{}\\n\", build_target_selection_directive(&sel)));","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/context/src/context_cli.rs#L562-L598","documentation":"This is the argument-validation funnel for the context CLI's load verb: `parse_target_options(args, true)` validates `--target` and related flags before any workspace resolution happens. On failure the returned message is printed verbatim to stderr and the process exits 1. Like error 55, the printed text is whatever the parser rejected.","triggerScenarios":"Invoking the context load command with malformed target options: unknown flags, `--target` given an invalid value/format, mutually conflicting target options, or a value that fails `parse_target_options` validation.","commonSituations":"Typoed flag names in scripts; passing `--target` with old syntax after a CLI change; combining target flags that the parser rejects; quoting mistakes in shell so the flag value is empty or split.","solutions":["Read the stderr line — the parser's message names the exact offending argument.","Fix or remove the invalid `--target`/option flag; check current CLI help for accepted syntax.","Quote values containing spaces or special characters so the parser receives one argument.","Omit target options entirely to fall back to auto-detected defaults when a target isn't required."],"exampleFix":"// before\ncontext load --target \"my workspace\" --targets other\n// <parse_target_options rejection>\n// after\ncontext load --target \"my workspace\"","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set(['--target', '--workspace', '--repo']);\nconst unknown = args.filter(a => a.startsWith('--') && !ALLOWED.has(a.split('=')[0]));\nif (unknown.length) throw new Error(`unknown target options: ${unknown.join(' ')}`);\nconst targetIdx = args.indexOf('--target');\nif (targetIdx !== -1 && (!args[targetIdx + 1] || args[targetIdx + 1].startsWith('--'))) {\n  throw new Error('--target requires a value');\n}","typeGuard":null,"tryCatchPattern":"const res = spawnSync('context', ['load', ...args], { encoding: 'utf8' });\nif (res.status !== 0 && /usage|invalid|unknown/i.test(res.stderr)) {\n  console.error('Bad target options:', res.stderr.trim());\n}","preventionTips":["Check `context load --help` for current option syntax after upgrades.","Quote option values containing spaces or special characters.","Don't combine conflicting target flags; pass one --target."],"tags":["cli","argument-parsing","invalid-flag"],"backgroundTag":"invalid-cli-argument","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}