{"record":{"id":"005a87e76ac8ddc7","repo":"aaif-goose/goose","slug":"unknown-error-occurred","errorCode":null,"errorMessage":"Unknown error occurred","messagePattern":"Unknown error occurred","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/goose-cli/src/recipes/github_recipe.rs","lineNumber":66,"sourceCode":"            Ok(download_dir) => match read_recipe_file(&download_dir) {\n                Ok((content, recipe_file_local_path)) => {\n                    return Ok(RecipeFile {\n                        content,\n                        parent_dir: download_dir.clone(),\n                        file_path: recipe_file_local_path,\n                    })\n                }\n                Err(err) => return Err(err),\n            },\n            Err(err) => {\n                last_err = Some(err);\n            }\n        }\n        if attempt < max_attempts {\n            clean_cloned_dirs(recipe_repo_full_name)?;\n        }\n    }\n    Err(last_err.unwrap_or_else(|| anyhow::anyhow!(\"Unknown error occurred\")))\n}\n\nfn clean_cloned_dirs(recipe_repo_full_name: &str) -> anyhow::Result<()> {\n    let local_repo_path = get_local_repo_path(&env::temp_dir(), recipe_repo_full_name)?;\n    if local_repo_path.exists() {\n        fs::remove_dir_all(&local_repo_path)?;\n    }\n    Ok(())\n}\nfn read_recipe_file(download_dir: &Path) -> Result<(String, PathBuf)> {\n    for ext in RECIPE_FILE_EXTENSIONS {\n        let candidate_file_path = download_dir.join(format!(\"recipe.{}\", ext));\n        if candidate_file_path.exists() {\n            let content = fs::read_to_string(&candidate_file_path)?;\n            println!(\n                \"⬇️  Retrieved recipe file: {}\",\n                candidate_file_path\n                    .strip_prefix(download_dir)","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/recipes/github_recipe.rs#L48-L84","documentation":"retrieve_recipe_from_github retries clone_and_download_recipe up to 2 attempts and always records failures in last_err (crates/goose-cli/src/recipes/github_recipe.rs:43-66). This 'Unknown error occurred' is the unreachable defensive fallback for the case where the loop finished but last_err was never set. With the hardcoded `max_attempts = 2`, every failing iteration stores an error, so in practice you should never see it.","triggerScenarios":"Only if the retry loop executed zero iterations or every iteration succeeded but returned without a value — both impossible with the current hardcoded max_attempts = 2 and straight-line Ok/Err handling. Encountering it indicates control flow was changed or corrupted.","commonSituations":"Virtually none in the shipped code; would only appear after someone edits the loop to conditionally skip storing errors (e.g., filtering which errors count as retryable) or sets max_attempts to 0.","solutions":["If you are seeing this in a modified build, inspect your changes to the retry loop in retrieve_recipe_from_github — a failure path is no longer recording last_err","Upstream, replace the opaque fallback with an error that includes attempt context so future edits cannot silently swallow the real cause"],"exampleFix":"// before\nErr(last_err.unwrap_or_else(|| anyhow::anyhow!(\"Unknown error occurred\")))\n\n// after\nErr(last_err.unwrap_or_else(|| {\n    anyhow::anyhow!(\"recipe download failed after {max_attempts} attempts with no recorded error\")\n}))","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Rust: the real error is in last_err; treat 'Unknown error occurred' as a bug signal\nif err.to_string().contains(\"Unknown error occurred\") {\n    // Control-flow bug in the retry loop: report upstream rather than retry blindly\n    report_issue_with_context();\n}","preventionTips":["When editing the retry loop, ensure every failure branch assigns last_err","Prefer exhaustive match arms that always record or return errors"],"tags":["goose-cli","recipes","defensive-code","unreachable"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}