{"record":{"id":"dbfa18a6970700ac","repo":"Hmbown/CodeWhale","slug":"github-release-request-failed-with-http-status","errorCode":null,"errorMessage":"GitHub release request failed with HTTP {status}: {body}","messagePattern":"GitHub release request failed with HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/release/src/lib.rs","lineNumber":284,"sourceCode":"        .await\n        .with_context(|| format!(\"failed to fetch {description} from {url}\"))?;\n    let status = response.status();\n    let body = response\n        .text()\n        .await\n        .with_context(|| format!(\"failed to read {description} response from {url}\"));\n    release_response_body(status, body, url, description)\n}\n\nfn release_response_body(\n    status: reqwest::StatusCode,\n    body: Result<String>,\n    url: &str,\n    description: &str,\n) -> Result<String> {\n    let body = body.with_context(|| format!(\"failed to read {description} response from {url}\"))?;\n    if !status.is_success() {\n        bail!(\"GitHub release request failed with HTTP {status}: {body}\");\n    }\n    Ok(body)\n}\n\n#[derive(Deserialize)]\nstruct ReleaseTag {\n    tag_name: String,\n}\n\n#[derive(Deserialize)]\nstruct ReleaseListEntry {\n    tag_name: String,\n}\n\n/// Extracts the `tag_name` field from a GitHub single-release JSON response.\npub fn latest_tag_from_release_json(body: &str) -> Result<String> {\n    let release: ReleaseTag = serde_json::from_str(body).with_context(|| {\n        format!(\"failed to parse release JSON from GitHub API. Response: {body}\")","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/release/src/lib.rs#L266-L302","documentation":"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).","triggerScenarios":"fetch_release_json_async -> release_response_body receives a non-2xx HTTP status from the GitHub releases API (GET /releases/tags/<tag> or similar).","commonSituations":"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).","solutions":["Read the embedded body: GitHub's JSON error message tells you the exact cause.","Verify the tag exists on the remote: git ls-remote --tags origin <tag>.","Set GITHUB_TOKEN (or gh auth token) to raise the rate limit and authenticate private repos.","Retry on 5xx / secondary rate limits after a backoff.","Confirm the repo owner/name and API URL are correct (github.com vs GHES)."],"exampleFix":"// before: unauthenticated request prone to 403\nlet body = fetch_release_json(&url, None).await?;\n// after: authenticate and pre-check the tag\nlet token = std::env::var(\"GITHUB_TOKEN\")?;\nensure_tag_pushed(&repo, &tag)?;\nlet body = fetch_release_json(&url, Some(&token)).await?;","handlingStrategy":"retry","validationCode":"// Check auth and tag existence before calling the API\nlet token = std::env::var(\"GITHUB_TOKEN\").ok();\nlet tag_exists = std::process::Command::new(\"git\")\n    .args([\"ls-remote\", \"--tags\", &repo_url, &tag])\n    .output()?.status.success();","typeGuard":"fn is_github_rate_limit(status: u16, body: &str) -> bool {\n    status == 403 && body.contains(\"rate limit\")\n}","tryCatchPattern":"match fetch_release_json(url).await {\n    Ok(body) => body,\n    Err(e) if e.to_string().contains(\"HTTP 403\") => retry_with_backoff(token_authed(url)).await?,\n    Err(e) if e.to_string().contains(\"HTTP 404\") => bail!(\"tag not pushed yet: {tag}\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Always set GITHUB_TOKEN in CI and locally","Push and verify the tag before fetching its release","Back off and retry on 5xx / secondary rate limits","Confirm the repo slug/owner after renames or transfers"],"tags":["github","http","release"],"backgroundTag":"http-error-response","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}