{"record":{"id":"ea02f5a878fff02e","repo":"pbakaus/impeccable","slug":"unknown-action-action-valid-actions-join","errorCode":null,"errorMessage":"Unknown action: {action}\nValid: {ACTIONS.join(\", \")}\n","messagePattern":"Unknown action: (.+?)\nValid: (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/hook/src/admin.rs","lineNumber":1269,"sourceCode":"    if parts.is_empty() {\n        \"No hook config or cache to remove. Already at defaults.\".to_string()\n    } else {\n        parts.join(\" \")\n    }\n}\n\n/// `impeccable hooks [action] [args...]` (hook-admin.mjs main). Returns the exit code.\npub fn run(rt: &Runtime, args: &[String], io: &mut impeccable_common::Io) -> i32 {\n    let action = js::to_lower_case(\n        args.first()\n            .map(String::as_str)\n            .filter(|a| !a.is_empty())\n            .unwrap_or(\"status\"),\n    );\n    let rest: Vec<String> = args.iter().skip(1).cloned().collect();\n    let cwd = rt.proc_cwd.clone();\n    if !ACTIONS.contains(&action.as_str()) {\n        io.err(&format!(\n            \"Unknown action: {action}\\nValid: {}\\n\",\n            ACTIONS.join(\", \")\n        ));\n        return 1;\n    }\n    let out = match action.as_str() {\n        \"status\" => Ok(status_report(rt, &cwd)),\n        \"on\" => set_enabled(rt, &cwd, true),\n        \"off\" => set_enabled(rt, &cwd, false),\n        \"ignore-rule\" => add_ignore_rule(rt, &cwd, &rest),\n        \"ignore-file\" => add_ignore_file(rt, &cwd, &rest),\n        \"ignore-value\" => add_ignore_value(rt, &cwd, &rest),\n        \"reset\" => Ok(reset(rt, &cwd)),\n        _ => Ok(String::new()),\n    };\n    match out {\n        Ok(text) => {\n            io.out(&format!(\"{text}\\n\"));","sourceCodeStart":1251,"sourceCodeEnd":1287,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/hook/src/admin.rs#L1251-L1287","documentation":"The hook admin command validates its first argument against the ACTIONS list before dispatching. If the action (defaulting to \"status\" when absent/empty) is not one of the known actions, run() prints \"Unknown action: <action>\" plus the comma-joined valid list to stderr and exits 1. This is the admin subcommand's action-name guard.","triggerScenarios":"Running `impeccable hook-admin <action>` (or the equivalent admin entry point) with a misspelled or unsupported action name — anything not contained in ACTIONS, e.g. `stat`, `enable-all`, or a flag accidentally in the action position.","commonSituations":"Typo'd action names; scripts written against a different tool's admin verbs; passing flags like `--json` as the first argument so they are parsed as the action.","solutions":["Read the \"Valid: ...\" list in the message and re-run with an exact action name from it","Omit the action entirely to get the default \"status\" behavior","Check argument order — flags must come after the action, not in its position","Consult the admin subcommand's help/USAGE for the authoritative action set"],"exampleFix":"// before\n$ impeccable admin stat\nUnknown action: stat\nValid: status, ...\n\n// after\n$ impeccable admin status","handlingStrategy":"validation","validationCode":"// Obtain ACTIONS from the error/help surface and validate before invoking\nconst KNOWN = new Set(actionListFromHelp()); // e.g. includes 'status'\nif (!KNOWN.has(action)) throw new Error(`unknown admin action: ${action}`);","typeGuard":null,"tryCatchPattern":"const res = spawnSync('impeccable', ['admin', action, ...rest]);\nif (res.status !== 0 && res.stderr.toString().startsWith('Unknown action')) {\n  const valid = res.stderr.toString().match(/Valid: (.+)/)?.[1]?.split(', ');\n  console.error(`pick one of: ${valid?.join(', ')}`);\n}","preventionTips":["Default to the implicit 'status' action instead of guessing names","Keep flags after the action argument, never in position 1","Re-read the Valid list after version upgrades — ACTIONS may change"],"tags":["cli","argument-parsing"],"backgroundTag":"invalid-enum-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"}