{"record":{"id":"8e71da6c74f8054a","repo":"pbakaus/impeccable","slug":"serve-question-update-payload-needs-an-options","errorCode":null,"errorMessage":"serve-question: --update payload needs an options array; nothing was delivered. Fix the payload and rerun --update on the same key.\n","messagePattern":"serve-question: --update payload needs an options array; nothing was delivered\\. Fix the payload and rerun --update on the same key\\.\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/context/src/serve_question.rs","lineNumber":303,"sourceCode":"        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        }\n        let delivered = next_file(&qdir, &key);\n        let _ = std::fs::copy(jsp::resolve(&cwd, &[&pp]), &delivered);\n        touch_now(&delivered);\n        io.out(\"next round delivered; the page reloads itself\\n\");\n        return 0;\n    }\n\n    if a.has(\"start\") {\n        let Some(pp) = payload_path.clone() else {\n            io.err(\"serve-question: --start needs --payload <file>\\n\");\n            return 1;\n        };","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/context/src/serve_question.rs#L285-L321","documentation":"After the --update payload is read, run() checks that it contains a non-empty options array. If the payload lacks options or has an empty options array, the round is not delivered: this message is printed, exit code 1, and the caller is told to fix the payload and rerun --update on the same key.","triggerScenarios":"--update payload JSON that has no 'options' key, has options as a non-array, or has an empty options array.","commonSituations":"Hand-written payloads missing the options field; generators producing empty option lists when upstream data is missing; reusing a payload template with placeholders unfilled.","solutions":["Add a non-empty 'options' array to the payload JSON and re-run --update with the same --key.","Check upstream data generation if options came out empty.","Validate payload structure (options present, array, length > 0) before invoking."],"exampleFix":"// before\n{\"question\":\"Next step?\"}\n// after\n{\"question\":\"Next step?\",\"options\":[\"Retry\",\"Abort\"]}","handlingStrategy":"validation","validationCode":"const payload = JSON.parse(fs.readFileSync(payloadPath, 'utf8'));\nif (!Array.isArray(payload.options) || payload.options.length === 0) {\n  throw new Error('payload.options must be a non-empty array');\n}","typeGuard":"const hasOptions = (p) => Array.isArray(p?.options) && p.options.length > 0;","tryCatchPattern":"if (res.status === 1 && res.stderr.includes('needs an options array')) {\n  // regenerate/repair the payload, keep the SAME --key, and rerun --update\n}","preventionTips":["Validate payload schema (question + non-empty options) at generation time","Fail the payload producer when its upstream option list is empty","Keep a schema check shared between payload generation and delivery"],"tags":["cli","validation","json-schema"],"backgroundTag":"schema-validation-failed","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"}