Hmbown/CodeWhale · error

GitHub release request failed with HTTP

Error message

GitHub release request failed with HTTP {status}: {body}

What it means

When fetching a GitHub release's JSON metadata, the release module reads the HTTP response body and checks the status code. Any non-success status (404 for a missing tag, 403 rate limit, 5xx) aborts with this error that embeds the HTTP status and the raw response body. The body is included precisely so the caller can see GitHub's error JSON (e.g. message: Not Found).

Solutions

  1. Read the embedded body: GitHub's JSON error message tells you the exact cause.
  2. Verify the tag exists on the remote: git ls-remote --tags origin <tag>.
  3. Set GITHUB_TOKEN (or gh auth token) to raise the rate limit and authenticate private repos.
  4. Retry on 5xx / secondary rate limits after a backoff.
  5. Confirm the repo owner/name and API URL are correct (github.com vs GHES).

Example fix

// before: unauthenticated request prone to 403
let body = fetch_release_json(&url, None).await?;
// after: authenticate and pre-check the tag
let token = std::env::var("GITHUB_TOKEN")?;
ensure_tag_pushed(&repo, &tag)?;
let body = fetch_release_json(&url, Some(&token)).await?;
Defensive patterns

Strategy: retry

Validate before calling

// Check auth and tag existence before calling the API
let token = std::env::var("GITHUB_TOKEN").ok();
let tag_exists = std::process::Command::new("git")
    .args(["ls-remote", "--tags", &repo_url, &tag])
    .output()?.status.success();

Type guard

fn is_github_rate_limit(status: u16, body: &str) -> bool {
    status == 403 && body.contains("rate limit")
}

Try / catch

match fetch_release_json(url).await {
    Ok(body) => body,
    Err(e) if e.to_string().contains("HTTP 403") => retry_with_backoff(token_authed(url)).await?,
    Err(e) if e.to_string().contains("HTTP 404") => bail!("tag not pushed yet: {tag}"),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: fetch_release_json_async -> release_response_body receives a non-2xx HTTP status from the GitHub releases API (GET /releases/tags/<tag> or similar).

Common situations: Releasing a tag that hasn't been pushed yet (404); unauthenticated GitHub API calls exceeding the 60 req/hour rate limit (403); missing GITHUB_TOKEN in CI; repo renamed or moved; GitHub incidents (5xx).

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 Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/dbfa18a6970700ac. Report an issue: GitHub.

Appendix: source

Thrown at crates/release/src/lib.rs:284

        .await
        .with_context(|| format!("failed to fetch {description} from {url}"))?;
    let status = response.status();
    let body = response
        .text()
        .await
        .with_context(|| format!("failed to read {description} response from {url}"));
    release_response_body(status, body, url, description)
}

fn release_response_body(
    status: reqwest::StatusCode,
    body: Result<String>,
    url: &str,
    description: &str,
) -> Result<String> {
    let body = body.with_context(|| format!("failed to read {description} response from {url}"))?;
    if !status.is_success() {
        bail!("GitHub release request failed with HTTP {status}: {body}");
    }
    Ok(body)
}

#[derive(Deserialize)]
struct ReleaseTag {
    tag_name: String,
}

#[derive(Deserialize)]
struct ReleaseListEntry {
    tag_name: String,
}

/// Extracts the `tag_name` field from a GitHub single-release JSON response.
pub fn latest_tag_from_release_json(body: &str) -> Result<String> {
    let release: ReleaseTag = serde_json::from_str(body).with_context(|| {
        format!("failed to parse release JSON from GitHub API. Response: {body}")

View on GitHub (pinned to 73e0f67d83)