{"record":{"id":"5cc6dfdb39d2e30e","repo":"nikivdev/code","slug":"no-prompt-provided-for-flow-agent","errorCode":null,"errorMessage":"No prompt provided for flow agent.","messagePattern":"No prompt provided for flow agent\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/agents.rs","lineNumber":952,"sourceCode":"    cmd.arg(prompt)\n        .stdin(Stdio::inherit())\n        .stdout(Stdio::inherit())\n        .stderr(Stdio::inherit())\n        .status()\n        .context(\"failed to run opencode\")\n}\n\n/// Run the flow agent and capture the final text output.\npub fn run_flow_agent_capture(prompt: &str) -> Result<String> {\n    let gen_loc = find_gen().ok_or_else(|| {\n        anyhow::anyhow!(\n            \"gen not found. Install with:\\n  cd {} && f install\\n  # or set GEN_REPO env var\",\n            gen_repo_hint()\n        )\n    })?;\n\n    if prompt.trim().is_empty() {\n        bail!(\"No prompt provided for flow agent.\");\n    }\n\n    let full_prompt = build_flow_prompt(prompt)?;\n    invoke_gen_capture(&gen_loc, &full_prompt)\n}\n\n/// Run the flow agent and stream text output while capturing the final response.\npub fn run_flow_agent_capture_streaming(prompt: &str) -> Result<String> {\n    let gen_loc = find_gen().ok_or_else(|| {\n        anyhow::anyhow!(\n            \"gen not found. Install with:\\n  cd {} && f install\\n  # or set GEN_REPO env var\",\n            gen_repo_hint()\n        )\n    })?;\n\n    if prompt.trim().is_empty() {\n        bail!(\"No prompt provided for flow agent.\");\n    }","sourceCodeStart":934,"sourceCodeEnd":970,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/agents.rs#L934-L970","documentation":"run_flow_agent_capture resolves the gen location (bailing earlier if gen is missing) and then validates that the prompt is non-empty (after trimming whitespace) before building the flow prompt. An empty/whitespace-only prompt causes this bail; the function exists to capture gen's output rather than stream it.","triggerScenarios":"Calling the public run_flow_agent_capture with \"\", whitespace, or a programmatically supplied prompt that resolved to empty; the gen-location check already passed at this point.","commonSituations":"Library/CLI callers building a flow-agent request from an empty config field or unset variable; UI passing through an untouched input box.","solutions":["Pass non-empty prompt text to run_flow_agent_capture.","Trim and validate the prompt at the call site before invoking.","Ensure the config field or variable feeding the prompt is populated.","If the prompt should come from a file/stdin, read and verify it before calling."],"exampleFix":"// before\nrun_flow_agent_capture(loc, \"\")?; // panics/bails\n// after\nlet prompt = cfg.prompt.trim();\nanyhow::ensure!(!prompt.is_empty(), \"prompt required\");\nrun_flow_agent_capture(loc, prompt)?;","handlingStrategy":"validation","validationCode":"let p = prompt.trim();\nif p.is_empty() { return Err(anyhow::anyhow!(\"prompt required\")); }\nrun_flow_agent_capture(&loc, p)?;","typeGuard":"fn is_valid_prompt(p: &str) -> bool {\n    !p.trim().is_empty()\n}","tryCatchPattern":"match run_flow_agent_capture(&loc, prompt) {\n    Err(e) if e.to_string().contains(\"No prompt provided for flow agent\") => {\n        eprintln!(\"Supply non-empty prompt text.\");\n    }\n    other => other?,\n}","preventionTips":["Trim and check prompts at every call site.","Never pass UI/config strings straight through without an emptiness check.","Centralize prompt validation in one helper used by both capture and streaming paths.","Require explicit prompt fields in configs consuming this API."],"tags":["agent","validation","flow"],"backgroundTag":"missing-required-argument","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}