jdx/mise · error

tap {directory} directory tree was truncated

Error message

tap {directory} directory tree was truncated

What it means

After finding the active formula directory in a tap, the library fetches that directory's tree recursively via the GitHub trees API (?recursive=1). If that response is truncated=true, GitHub dropped entries, so the formula file listing would be incomplete and the library bails with this error.

Source

Thrown at src/system/packages/brew/tap.rs:274

            tap_source.api_base, tap_source.commit
        ))
        .await
        .wrap_err("failed to inspect tap formula directories")?;
    if root_tree.truncated {
        bail!("tap repository tree was truncated");
    }

    let (directory, formula_tree) =
        if let Some((directory, sha)) = active_formula_directory(&root_tree) {
            let tree: GithubTree = HTTP_FETCH
                .json_cached(format!(
                    "{}/git/trees/{sha}?recursive=1",
                    tap_source.api_base
                ))
                .await
                .wrap_err_with(|| format!("failed to inspect tap {directory} directory"))?;
            if tree.truncated {
                bail!("tap {directory} directory tree was truncated");
            }
            (directory, tree)
        } else {
            ("", root_tree)
        };

    let source_path = formula_source_path(directory, &formula_tree, name).ok_or_else(|| {
        let location = if directory.is_empty() {
            "repository root"
        } else {
            directory
        };
        eyre::eyre!("tap has no formula named '{name}' in {location}")
    })?;
    let source = HTTP_FETCH
        .get_text(ruby_source_url(&tap_source.raw_base, &source_path))
        .await
        .wrap_err_with(|| format!("failed to fetch tap formula {source_path}"))?;

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Retry, though for oversized directories it will likely recur.
  2. Clone the tap with git and enumerate the formula directory on disk instead of using the recursive trees API.
  3. Request the non-recursive tree and fetch subdirectories individually to stay under limits.
  4. Use the git blobs/contents API per file or the codeload tarball to enumerate files.

Example fix

// before
let tree: GithubTree = HTTP_FETCH.json_cached(format!("{api_base}/git/trees/{sha}?recursive=1")).await?;
// after: fall back to local clone on truncation
let tree = if tree.truncated { clone_and_list_dir(tap_url, sha, directory).await? } else { tree };
Defensive patterns

Strategy: fallback

Validate before calling

let tree: GithubTree = resp.json().await?;
if tree.truncated { /* switch to clone-based enumeration */ }

Type guard

fn is_full_directory_tree(t: &GithubTree) -> bool { !t.truncated }

Try / catch

match fetch_formula_source(tap, name).await {
    Err(e) if e.to_string().contains("was truncated") => enumerate_formulas_from_clone(tap).await,
    other => other,
}

Prevention

When it happens

Trigger: fetch_formula_source issues GET {api_base}/git/trees/{sha}?recursive=1 for a tap's formula directory and the response contains truncated=true — the directory (recursively) exceeds GitHub's tree API result limits.

Common situations: Taps whose Formula/ (or active) directory contains thousands of files; recursive listing of a directory with deep/large subtrees; large community taps exceeding GitHub's ~100k-entry / 7MB tree limits.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/b3e078f73443bb4c. Report an issue: GitHub.