{"record":{"id":"9399d14ebfe471a3","repo":"pbakaus/impeccable","slug":"serve-question-update-needs-key-and-payload","errorCode":null,"errorMessage":"serve-question: --update needs --key and --payload\n","messagePattern":"serve-question: --update needs --key and --payload\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/context/src/serve_question.rs","lineNumber":291,"sourceCode":"        let Some(key) = a.arg(\"key\") else {\n            io.err(\"serve-question: --stop needs --key\\n\");\n            return 1;\n        };\n        if let Some(state) = read_state(&qdir, &key) {\n            if let Some(pid) = state.get(\"pid\").and_then(|p| p.as_f64()) {\n                kill_pid(pid as i64);\n            }\n        }\n        let _ = std::fs::remove_file(answer_file(&qdir, &key));\n        let _ = std::fs::remove_file(state_file(&qdir, &key));\n        io.out(\"stopped\\n\");\n        return 0;\n    }\n\n    if a.has(\"update\") {\n        let key = a.arg(\"key\");\n        let (Some(key), Some(pp)) = (key, payload_path.clone()) else {\n            io.err(\"serve-question: --update needs --key and --payload\\n\");\n            return 1;\n        };\n        let next_round = match read_json_file(&jsp::resolve(&cwd, &[&pp])) {\n            Ok(v) => v,\n            Err(msg) => {\n                io.err(&format!(\"{}\\n\", msg));\n                return 1;\n            }\n        };\n        let ok = next_round.get(\"options\").and_then(|o| o.as_array()).map(|o| !o.is_empty()).unwrap_or(false);\n        if !ok {\n            io.err(\"serve-question: --update payload needs an options array; nothing was delivered. Fix the payload and rerun --update on the same key.\\n\");\n            return 1;\n        }\n        if !is_alive(&qdir, &key) {\n            io.err(\"serve-question: no live question server for that key; the page it served is gone too. Re-present the round with --start and a fresh key, or fall back to the structured question tool.\\n\");\n            return 2;\n        }","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/context/src/serve_question.rs#L273-L309","documentation":"The --update flag delivers a follow-up round to a live question page, and it needs both --key (which question) and --payload (the JSON file describing the next round). If either is missing, run() prints this message and exits 1.","triggerScenarios":"Invoking `serve-question --update` with neither or only one of `--key <key>` and `--payload <file>`.","commonSituations":"Multi-round question flows where the second call forgets the payload path; scripts templating only part of the command; refactoring --start calls to --update without carrying the payload argument over.","solutions":["Supply both --key (from --start) and --payload pointing at a JSON file.","Validate that both shell variables are non-empty before invoking.","If the payload is missing, write the next-round JSON (with an options array) first, then update."],"exampleFix":"// before\nserve-question --update --key q-123\n// after\nserve-question --update --key q-123 --payload round2.json","handlingStrategy":"validation","validationCode":"if (args.includes('--update') && !(args.includes('--key') && args.includes('--payload'))) {\n  throw new Error('serve-question --update requires both --key and --payload');\n}","typeGuard":"null","tryCatchPattern":"const res = spawnSync('serve-question', args);\nif (res.status === 1 && res.stderr.includes('--update needs --key and --payload')) {\n  // re-invoke with both arguments supplied\n}","preventionTips":["Build the update command from a helper that always takes (key, payloadPath)","Check both values are non-empty strings before spawning","Keep --start and --update argument shapes symmetric in scripts"],"tags":["cli","argument-validation","multi-round"],"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"}