{"record":{"id":"d98b011ff1a1f2b3","repo":"aaif-goose/goose","slug":"no-text-provided-for-prompt-in-headless-mode","errorCode":null,"errorMessage":"no text provided for prompt in headless mode","messagePattern":"no text provided for prompt in headless mode","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/goose-cli/src/cli.rs","lineNumber":1955,"sourceCode":"\n    if run_behavior.interactive {\n        session.interactive(input_config.contents).await\n    } else if let Some(contents) = input_config.contents {\n        let session_start = std::time::Instant::now();\n        let session_type = if recipe.is_some() { \"recipe\" } else { \"run\" };\n\n        tracing::info!(\n            monotonic_counter.goose.session_starts = 1,\n            session_type,\n            interactive = false,\n            \"Headless session started\"\n        );\n\n        let result = session.headless(contents).await;\n        log_session_completion(&session, session_start, session_type, result.is_ok()).await;\n        result\n    } else {\n        Err(anyhow::anyhow!(\n            \"no text provided for prompt in headless mode\"\n        ))\n    }\n}\n\nasync fn handle_gateway_command(command: GatewayCommand) -> Result<()> {\n    use crate::commands::gateway;\n\n    match command {\n        GatewayCommand::Status {} => gateway::handle_gateway_status().await,\n        GatewayCommand::Start {\n            gateway_type,\n            bot_token,\n        } => {\n            let platform_config = serde_json::json!({ \"bot_token\": bot_token });\n            gateway::handle_gateway_start(gateway_type, platform_config).await\n        }\n        GatewayCommand::Stop { gateway_type } => gateway::handle_gateway_stop(gateway_type).await,","sourceCodeStart":1937,"sourceCodeEnd":1973,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/cli.rs#L1937-L1973","documentation":"In headless (non-interactive) execution the CLI must be given prompt text, either as CLI arguments or via stdin. If the assembled `contents` is empty when no interactive branch applies, goose fails before creating a session.","triggerScenarios":"Invoking the headless path with no prompt argument and empty/closed stdin (e.g. `goose run` inside CI with no input), or piping an empty string into the stdin prompt path.","commonSituations":"CI jobs or cron scripts calling goose without arguments; `echo \"\" | goose run` style pipelines; scripts assuming goose falls back to interactive mode when stdin is not a TTY.","solutions":["Pass the prompt text explicitly, e.g. `goose run \"your instruction\"`","Pipe non-empty content via the stdin headless path (`goose run -i -` with piped text)","If an interactive REPL was intended, run goose inside a real terminal","Guard wrapper scripts: fail early when the prompt variable is empty"],"exampleFix":"# before\ngoose run                        # no text, non-TTY stdin -> error\n\n# after\ngoose run \"Summarize this repository\"\n# or\ncat prompt.txt | goose run -i -","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nPROMPT=\"$1\"\n[ -n \"$PROMPT\" ] || { echo 'error: prompt text is required in headless mode' >&2; exit 2; }\nexec goose run \"$PROMPT\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass prompts positionally or via stdin in automation","Never assume interactive fallback in non-TTY contexts","Assert non-empty input in CI steps before invoking goose"],"tags":["headless","cli","input-validation","scripting"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}