{"record":{"id":"a4509f8b930a7811","repo":"pbakaus/impeccable","slug":"embed-prompt-prompt-or-prompt-file-required","errorCode":null,"errorMessage":"embed-prompt: --prompt or --prompt-file required\n","messagePattern":"embed-prompt: --prompt or --prompt-file required\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/context/src/embed_prompt.rs","lineNumber":276,"sourceCode":"                0\n            }\n        }\n    } else {\n        let prompt = match arg_of(\"--prompt\") {\n            Some(p) => Some(p),\n            None => match arg_of(\"--prompt-file\") {\n                Some(pf) if !pf.is_empty() => match std::fs::read(abs(&pf)) {\n                    Ok(b) => Some(String::from_utf8_lossy(&b).into_owned()),\n                    Err(e) => {\n                        io.err(&format!(\"Error: {}\\n\", crate::util::node_read_error(&pf, &e)));\n                        return 1;\n                    }\n                },\n                _ => None,\n            },\n        };\n        let Some(prompt) = prompt.filter(|p| !p.is_empty()) else {\n            io.err(\"embed-prompt: --prompt or --prompt-file required\\n\");\n            return 1;\n        };\n        let plen = utf16_len(&prompt);\n        if png {\n            // JS-PARITY: embed-prompt.mjs#641 finds IEND by walking the PNG\n            // chunks (not buf.indexOf('IEND')) and reuses parsePng's chunk list\n            // and prompt to rebuild the body idempotently.\n            let (chunks, existing) = parse_png(&buf);\n            let iend: i64 = chunks.iter().find(|c| &c.ty == b\"IEND\").map(|c| c.offset as i64).unwrap_or(-1);\n            if iend < 8 {\n                io.err(\"embed-prompt: malformed PNG\\n\");\n                return 1;\n            }\n            let iend = iend as usize;\n            let mut text_data = KEYWORD.to_vec();\n            text_data.push(0);\n            text_data.extend_from_slice(prompt.as_bytes());\n            let text_chunk = png_chunk(b\"tEXt\", &text_data);","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/context/src/embed_prompt.rs#L258-L294","documentation":"Guard at the top of embed_prompt's non-help path: after checking --prompt and --prompt-file (reading the file if given), the resolved prompt is either absent or empty after filtering. Fires when the user supplied neither flag, or the prompt-file's contents were blank.","triggerScenarios":"Running embed-prompt in write mode with neither --prompt nor --prompt-file, passing --prompt \"\" (empty), or pointing --prompt-file at an empty file.","commonSituations":"Shell variable holding the prompt was unset (empty interpolation), a prompt-file created but never written by an upstream step, or forgetting the flag entirely.","solutions":["Pass a non-empty prompt: `--prompt \"your prompt text\"`.","If using --prompt-file, confirm the file has content (wc -c prompt.txt).","Check the shell variable feeding --prompt is actually set (${VAR:?} guard in scripts)."],"exampleFix":"// before\nimpeccable embed-prompt --image out.png --prompt \"$PROMPT\"\n// after\nimpeccable embed-prompt --image out.png --prompt \"${PROMPT:?PROMPT is unset}\"","handlingStrategy":"validation","validationCode":"[ -n \"$PROMPT\" ] || [ -s \"$PROMPT_FILE\" ] || { echo \"prompt required\" >&2; exit 1; }","typeGuard":"const hasPrompt = (s) => typeof s === 'string' && s.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Use ${VAR:?msg} to fail fast on unset prompt variables","Check prompt files are non-empty (wc -c) before passing","Never build CLI commands by naive string interpolation of optional args"],"tags":["cli","missing-argument","empty-value"],"backgroundTag":"missing-required-argument","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"}