{"record":{"id":"b1bdf0a6820d3d5a","repo":"aaif-goose/goose","slug":"failed-to-authenticate-using-github-cli","errorCode":null,"errorMessage":"Failed to authenticate using GitHub CLI.","messagePattern":"Failed to authenticate using GitHub CLI\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose-cli/src/recipes/github_recipe.rs","lineNumber":126,"sourceCode":"        .args([\"auth\", \"status\"])\n        .set_no_window()\n        .status()\n        .map_err(|_| {\n            anyhow::anyhow!(\"Failed to run `gh auth status`. Make sure you have `gh` installed.\")\n        })?;\n\n    if status.success() {\n        return Ok(());\n    }\n    println!(\"GitHub CLI is not authenticated. Launching `gh auth login`...\");\n    // Run `gh auth login` interactively\n    let login_status = Command::new(\"gh\")\n        .args([\"auth\", \"login\", \"--git-protocol\", \"https\"])\n        .status()\n        .map_err(|_| anyhow::anyhow!(\"Failed to run `gh auth login`\"))?;\n\n    if !login_status.success() {\n        Err(anyhow::anyhow!(\"Failed to authenticate using GitHub CLI.\"))\n    } else {\n        Ok(())\n    }\n}\n\nfn temp_child_name(name: &str) -> String {\n    let mut child = String::with_capacity(name.len());\n    for ch in name.chars() {\n        match ch {\n            '/' | '\\\\' => child.push_str(\"__\"),\n            ch if ch.is_ascii_alphanumeric() || ch == '-' || ch == '_' || ch == '.' => {\n                child.push(ch)\n            }\n            _ => child.push('_'),\n        }\n    }\n\n    if child.is_empty() {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/recipes/github_recipe.rs#L108-L144","documentation":"goose ran interactive `gh auth login --git-protocol https` and the command executed but exited non-zero (crates/goose-cli/src/recipes/github_recipe.rs:125-128). Unlike [127], this is gh itself reporting that the login flow did not complete — the exit status is checked, and stderr from gh appears on the terminal around this error.","triggerScenarios":"User aborts the interactive prompt (Ctrl-C / EOF), the browser/device-code flow times out or fails, gh cannot prompt because stdin is not a TTY (piped input, some CI runners), or the chosen credentials are rejected.","commonSituations":"Running goose recipe commands in a non-interactive environment (CI, cron, scripts piping stdin), headless/SSH sessions without browser access where the device flow is interrupted, or an expired/revoked token causing gh to fail during login.","solutions":["Run `gh auth login` manually in an interactive terminal and complete the flow once, then re-run the goose command","For non-interactive environments, authenticate via a token: set GH_TOKEN/GITHUB_TOKEN env var (or `gh auth login --with-token < tokenfile`) instead of the interactive flow","Ensure stdin is attached to a TTY when interactive login is expected; do not pipe input into goose"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Skip interactive login entirely in automation: provide a token\nexport GH_TOKEN=\"ghp_xxx\"   # or GITHUB_TOKEN\ngh auth status >/dev/null && echo \"non-interactive auth OK\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Complete `gh auth login` manually before running goose recipe commands","Use GH_TOKEN for headless/CI environments instead of the interactive flow","Never pipe stdin into goose when an interactive gh prompt may appear"],"tags":["goose-cli","github-cli","authentication","interactive"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}