{"record":{"id":"dc17315c4c09cdf5","repo":"pbakaus/impeccable","slug":"serve-question-wait-needs-key","errorCode":null,"errorMessage":"serve-question: --wait needs --key\n","messagePattern":"serve-question: --wait needs --key\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/context/src/serve_question.rs","lineNumber":216,"sourceCode":"        }\n    }\n    let payload_path = a.arg(\"payload\");\n    let timeout_arg = js_number_arg(&a, \"timeout\", \"900\");\n    let timeout_sec = if timeout_arg.is_finite() && timeout_arg >= 0.0 { timeout_arg } else { 900.0 };\n    let idle_arg = js_number_arg(&a, \"idle-grace\", \"600\");\n    let idle_grace_ms = (if idle_arg.is_finite() && idle_arg > 0.0 { idle_arg } else { 600.0 }) * 1000.0;\n    let port_arg = js_number_arg(&a, \"port\", \"0\");\n    let qdir = jsp::join(&[&cwd, \".impeccable\", \"questions\"]);\n\n    if a.has(\"schema\") {\n        io.out(&format!(\"{}\\n\", json_pretty(&schema_json())));\n        io.out(&format!(\"{}\\n\", SCHEMA_NOTE));\n        return 0;\n    }\n\n    if a.has(\"wait\") {\n        let Some(key) = a.arg(\"key\") else {\n            io.err(\"serve-question: --wait needs --key\\n\");\n            return 1;\n        };\n        let poll_sec = js_number_arg(&a, \"poll\", \"60\");\n        let deadline = now_ms() + poll_sec * 1000.0;\n        let answered = || exists(&answer_file(&qdir, &key));\n        let mut saw_close = false;\n        while now_ms() < deadline {\n            if answered() {\n                break;\n            }\n            if exists(&flip_file(&qdir, &key)) {\n                let _ = std::fs::remove_file(flip_file(&qdir, &key));\n                io.out(\"BUILD PATH FLIPPED: comp (for this session only; never write it to settings). The table is still open and the page shows shimmer where the images will land: generate each open card’s comp into its declared path now, lead first, then collect the answer with --wait again. A card whose comp already exists needs nothing.\\n\");\n                return 0;\n            }\n            if !is_alive(&qdir, &key) {\n                io.out(\"serve-question: the question server is gone with no answer. This is a server failure, not a user decision: restart it with --start and the same payload, reopen the URL for the user, and wait again. Never proceed without their choice while their browser session is open.\\n\");\n                return 2;","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/context/src/serve_question.rs#L198-L234","documentation":"serve-question's --wait flag polls for an answer file for a previously started question, and it requires --key to identify which question to wait on. If --wait is given without --key, run() prints this message and exits 1 rather than guessing which question is meant.","triggerScenarios":"Invoking `serve-question --wait` (optionally with --poll) while omitting the `--key <key>` argument that identifies the question directory.","commonSituations":"Scripting the poll step after a session restart and losing the key; assuming --wait applies to the most recent question; shell variable holding the key is unset.","solutions":["Pass the same --key value that was used with the original --start invocation.","If the key is unknown, re-present the question with --start and a freshly generated key.","In scripts, fail fast if the key variable is empty before calling serve-question."],"exampleFix":"// before\nserve-question --wait --poll 30\n// after\nserve-question --wait --key <key-from-start> --poll 30","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(2);\nif (args.includes('--wait') && !args.includes('--key')) {\n  throw new Error('serve-question --wait requires --key');\n}","typeGuard":"null","tryCatchPattern":"const res = spawnSync('serve-question', args);\nif (res.status === 1 && res.stderr.includes('--wait needs --key')) {\n  // abort: re-invoke with the key from the original --start\n}","preventionTips":["Persist the --start key to a file/env and always read it back for --wait/--stop/--update","Fail fast in scripts when the key variable is empty","Remember --wait never defaults to 'the latest question'"],"tags":["cli","argument-validation","polling"],"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-14T00:17:10.932Z"}