{"record":{"id":"0c8ede5696c54190","repo":"pbakaus/impeccable","slug":"error-scope-requires-a-value-valid-scopes-sc","errorCode":null,"errorMessage":"Error: --scope requires a value. Valid scopes: {scopes_valid}\n","messagePattern":"Error: --scope requires a value\\. Valid scopes: (.+?)\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/detect/src/cli.rs","lineNumber":450,"sourceCode":"        if args[i] != \"--scope\" && !inline {\n            i += 1;\n            continue;\n        }\n        let value: Option<String> = if inline {\n            Some(args[i][\"--scope=\".len()..].to_string())\n        } else {\n            args.get(i + 1).cloned()\n        };\n        let parsed: Vec<String> = match value {\n            Some(v) if !v.starts_with(\"--\") => v\n                .split(',')\n                .map(|s| impeccable_core::js::trim(s).to_string())\n                .filter(|s| !s.is_empty())\n                .collect(),\n            _ => vec![],\n        };\n        if parsed.is_empty() {\n            io.err(&format!(\n                \"Error: --scope requires a value. Valid scopes: {scopes_valid}\\n\"\n            ));\n            return Err(Exit(1));\n        }\n        scopes.extend(parsed);\n        let n = if inline { 1 } else { 2 };\n        for _ in 0..n {\n            if i < args.len() {\n                args.remove(i);\n            }\n        }\n    }\n    let mut viewport: Option<(u32, u32)> = None;\n    let mut i = 0;\n    while i < args.len() {\n        let inline = args[i].starts_with(\"--viewport=\");\n        if args[i] != \"--viewport\" && !inline {\n            i += 1;","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/detect/src/cli.rs#L432-L468","documentation":"The detect CLI exits with code 1 when `--scope` is given without any usable value: after parsing the flag's value (inline `--scope=...` or the next argument), splitting on commas, and trimming, the resulting list is empty. The message lists the valid scope names so the caller can correct the flag.","triggerScenarios":"Running `impeccable detect --scope` with no following argument, `--scope=` with an empty value, or `--scope ,,` / whitespace-only values that trim to nothing.","commonSituations":"Script variables interpolating to empty (`--scope $SCOPES` with SCOPES unset); copied command lines where the scope value was stripped by a quoting bug; typos like `--scope: layout` that the parser doesn't recognize as inline form.","solutions":["Pass at least one valid scope value, e.g. `impeccable detect src/ --scope layout` (check the Valid scopes list printed in the message for exact names).","Use the comma-separated inline form for multiple scopes: `--scope=layout,spacing`.","Fix shell quoting/variable expansion so the value is not empty (e.g. `--scope \"${SCOPES:-all}\"` or guard the variable)."],"exampleFix":"// before\nimpeccable detect src/ --scope \"$MY_SCOPES\"   # MY_SCOPES empty\n// after\nimpeccable detect src/ --scope layout,spacing","handlingStrategy":"validation","validationCode":"const scopeFlagIdx = argv.indexOf(\"--scope\");\nconst val = scopeFlagIdx >= 0 ? argv[scopeFlagIdx + 1] : (argv.find(a => a.startsWith(\"--scope=\")) || \"=\").slice(8);\nif (!val || !val.split(\",\").some(s => s.trim())) {\n  throw new Error(\"--scope requires a non-empty comma-separated value\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never build --scope from possibly-empty shell variables without a default","Quote flag values to avoid the next arg being swallowed","Validate scope names against the CLI's valid list before invoking"],"tags":["cli","flags","validation","scope"],"backgroundTag":"missing-required-flag","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}