astrid-runtime/astrid · error

GitHub API returned {} for {org}/{repo} latest release

Error message

GitHub API returned {} for {org}/{repo} latest release

What it means

When no version pin is given, resolve_github_ref fetches the repo's latest release from the GitHub API. A non-success HTTP status on that call aborts with this error, including the returned status code.

Source

Thrown at crates/astrid-cli/src/commands/capsule/install_github.rs:94

                .with_context(|| format!("invalid GitHub API response for tag {candidate}"))?;
            return Ok(json
                .get("tag_name")
                .and_then(serde_json::Value::as_str)
                .unwrap_or(&candidate)
                .to_string());
        }
        bail!("no GitHub release found for version {version} in {org}/{repo}");
    }

    tracing::debug!(%org, %repo, "no version/tag pin — resolving latest release");
    let api_url = format!("https://api.github.com/repos/{org}/{repo}/releases/latest");
    let response = client
        .get(&api_url)
        .send()
        .await
        .context("failed to reach GitHub API for latest release")?;
    if !response.status().is_success() {
        bail!(
            "GitHub API returned {} for {org}/{repo} latest release",
            response.status()
        );
    }
    let json: serde_json::Value = response
        .json()
        .await
        .context("invalid GitHub API response")?;
    Ok(json
        .get("tag_name")
        .and_then(serde_json::Value::as_str)
        .unwrap_or("latest")
        .to_string())
}

View on GitHub (pinned to affd8760f4)

Solutions

  1. Set GITHUB_TOKEN and retry if you see 403/429 (rate limit).
  2. Pin an explicit version/tag to skip the /releases/latest lookup entirely.
  3. Confirm the repo exists and is public, or supply credentials for a private repo.
  4. Check GitHub status / your network if the status is 5xx.

Example fix

// before
astrid capsule install github:org/repo   # rate-limited 403 on latest-release lookup
// after
export GITHUB_TOKEN=ghp_...
astrid capsule install github:org/repo@1.4.0   # or keep unpinned with auth
Defensive patterns

Strategy: retry

Try / catch

match install_result {
    Err(e) if e.to_string().contains("GitHub API returned") && e.to_string().contains("429") => {
        tokio::time::sleep(Duration::from_secs(60)).await; // rate-limit window
        retry_install().await
    }
    other => other,
}

Prevention

When it happens

Trigger: install_from_github or resolve_capsule_to_file resolves an unpinned capsule; the GET to api.github.com/repos/{org}/{repo}/releases/latest returns a non-2xx status.

Common situations: Unauthenticated rate limiting (403 with rate-limit headers); the repo publishes releases but none are marked 'latest' (404); private repo without credentials (403); GitHub 5xx incidents; network middleboxes returning error pages.

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 astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/294c799d68e562d4. Report an issue: GitHub.