aaif-goose/goose · error

Failed to check directory contents: {}

Error message

Failed to check directory contents: {}

What it means

While discovering recipes, goose probes each top-level directory with `gh api repos/<repo>/contents/<dir>` (crates/goose-cli/src/recipes/github_recipe.rs:292-304). This error is the spawn io failure of that per-directory call — the gh process could not be executed. It carries the io error text, unlike the static variants elsewhere.

Source

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

                    }
                }
            }
        }
    }

    Ok(recipes)
}

fn check_github_directory_for_recipe(repo: &str, dir_name: &str) -> Result<RecipeInfo> {
    use serde_json::Value;
    use std::process::Command;

    // Check directory contents for recipe files
    let output = Command::new("gh")
        .args(["api", &format!("repos/{}/contents/{}", repo, dir_name)])
        .set_no_window()
        .output()
        .map_err(|e| anyhow!("Failed to check directory contents: {}", e))?;

    if !output.status.success() {
        return Err(anyhow!("Failed to access directory: {}", dir_name));
    }

    let contents: Value = serde_json::from_slice(&output.stdout)
        .map_err(|e| anyhow!("Failed to parse directory contents: {}", e))?;

    if let Some(items) = contents.as_array() {
        for item in items {
            if let Some(name) = item.get("name").and_then(|n| n.as_str()) {
                if RECIPE_FILE_EXTENSIONS
                    .iter()
                    .any(|ext| name == format!("recipe.{}", ext))
                {
                    // Found a recipe file, get its content
                    return get_github_recipe_info(repo, dir_name, name);
                }

View on GitHub (pinned to 3810898a74)

Solutions

  1. Verify gh still resolves right after the failure: `command -v gh`
  2. Re-run discovery; transient EAGAIN at spawn clears when load drops
  3. Stabilize the environment (consistent PATH, no mid-run binary swaps) for tooling that shells out repeatedly
Defensive patterns

Strategy: validation

Validate before calling

# Probe one directory the same way goose does
dir=$(gh api "repos/$GOOSE_RECIPE_GITHUB_REPO/contents" --jq '.[0].name')
gh api "repos/$GOOSE_RECIPE_GITHUB_REPO/contents/$dir" >/dev/null && echo "per-dir probe OK"

Prevention

When it happens

Trigger: Same io class as [135] but hit on the per-directory loop: gh removed from PATH or replaced mid-run, exec permission/format error, or process-creation resource limits reached while iterating many directories.

Common situations: Rare in practice since the parent call succeeded seconds earlier; appears with PATH instability in wrappers, concurrent gh upgrades, or containers hitting the process limit during discovery of large recipe repos.

Related errors


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