aaif-goose/goose · warning

Unknown error occurred

Error message

Unknown error occurred

What it means

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.

Source

Thrown at crates/goose-cli/src/recipes/github_recipe.rs:66

            Ok(download_dir) => match read_recipe_file(&download_dir) {
                Ok((content, recipe_file_local_path)) => {
                    return Ok(RecipeFile {
                        content,
                        parent_dir: download_dir.clone(),
                        file_path: recipe_file_local_path,
                    })
                }
                Err(err) => return Err(err),
            },
            Err(err) => {
                last_err = Some(err);
            }
        }
        if attempt < max_attempts {
            clean_cloned_dirs(recipe_repo_full_name)?;
        }
    }
    Err(last_err.unwrap_or_else(|| anyhow::anyhow!("Unknown error occurred")))
}

fn clean_cloned_dirs(recipe_repo_full_name: &str) -> anyhow::Result<()> {
    let local_repo_path = get_local_repo_path(&env::temp_dir(), recipe_repo_full_name)?;
    if local_repo_path.exists() {
        fs::remove_dir_all(&local_repo_path)?;
    }
    Ok(())
}
fn read_recipe_file(download_dir: &Path) -> Result<(String, PathBuf)> {
    for ext in RECIPE_FILE_EXTENSIONS {
        let candidate_file_path = download_dir.join(format!("recipe.{}", ext));
        if candidate_file_path.exists() {
            let content = fs::read_to_string(&candidate_file_path)?;
            println!(
                "⬇️  Retrieved recipe file: {}",
                candidate_file_path
                    .strip_prefix(download_dir)

View on GitHub (pinned to 3810898a74)

Solutions

  1. 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
  2. Upstream, replace the opaque fallback with an error that includes attempt context so future edits cannot silently swallow the real cause

Example fix

// before
Err(last_err.unwrap_or_else(|| anyhow::anyhow!("Unknown error occurred")))

// after
Err(last_err.unwrap_or_else(|| {
    anyhow::anyhow!("recipe download failed after {max_attempts} attempts with no recorded error")
}))
Defensive patterns

Strategy: try-catch

Try / catch

// Rust: the real error is in last_err; treat 'Unknown error occurred' as a bug signal
if err.to_string().contains("Unknown error occurred") {
    // Control-flow bug in the retry loop: report upstream rather than retry blindly
    report_issue_with_context();
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16). Data as JSON: /api/errors/005a87e76ac8ddc7. Report an issue: GitHub.