{"record":{"id":"fe801c9f7dc47a95","repo":"gitbutlerapp/gitbutler","slug":"github-graphql-returned-errors-messages","errorCode":null,"errorMessage":"GitHub GraphQL returned errors: {messages}","messagePattern":"GitHub GraphQL returned errors: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-github/src/client.rs","lineNumber":1852,"sourceCode":"    struct GraphQlError {\n        message: String,\n    }\n\n    #[derive(Deserialize)]\n    struct GraphQlResponse {\n        data: Option<serde_json::Value>,\n        errors: Option<Vec<GraphQlError>>,\n    }\n\n    let payload: GraphQlResponse = serde_json::from_slice(body)?;\n\n    if let Some(errors) = payload.errors {\n        let messages = errors\n            .into_iter()\n            .map(|error| error.message)\n            .collect::<Vec<_>>()\n            .join(\"; \");\n        bail!(\"GitHub GraphQL returned errors: {messages}\");\n    }\n\n    let Some(data) = payload.data else {\n        bail!(\"GitHub GraphQL response did not include data\");\n    };\n\n    Ok(serde_json::from_value(data)?)\n}\n\npub struct PullRequestNodeId {\n    id: String,\n}\n\nimpl PullRequestNodeId {\n    pub fn from_string(value: String) -> Self {\n        PullRequestNodeId { id: value }\n    }\n}","sourceCodeStart":1834,"sourceCodeEnd":1870,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-github/src/client.rs#L1834-L1870","documentation":"The GitHub GraphQL API responded successfully at the HTTP level but the response payload contained a top-level `errors` array, meaning GraphQL rejected or partially failed the query. The client joins all error messages with \"; \" and surfaces them so the caller sees GitHub's actual reason (e.g. throttling, bad nodes, permission issues).","triggerScenarios":"Any GraphQL query/mutation executed by crates/but-github's client (e.g. fetching PR node IDs or other PR data) where GitHub returns `errors` in the JSON payload — typically malformed queries, missing fields, resource-not-found node IDs, or rate-limit/throttle errors.","commonSituations":"Expired or insufficiently scoped token causing FORBIDDEN/INSUFFICIENT_SCOPES on a field; querying a PR that was deleted or is private; hitting GitHub GraphQL rate limits (query cost); a bug in the hand-written GraphQL query string after an API schema change.","solutions":["Read the joined message(s) in the error text — GitHub names the exact field and error code (e.g. FORBIDDEN, NOT_FOUND, RATE_LIMITED).","If RATE_LIMITED or throttling, wait until the rate-limit reset and add request pacing or reduce query cost.","If FORBIDDEN/INSUFFICIENT_SCOPES, regenerate the token with the required scopes (repo / workflow as needed).","If NOT_FOUND on a node, verify the PR number/owner/repo and that the entity still exists.","If a field is unknown, update the GraphQL query to match the current GitHub schema."],"exampleFix":"// before: fire-and-forget GraphQL call that may be rate limited\nlet prs = client.pull_request_node_id(owner, repo, number).await?;\n\n// after: pre-flight a rate-limit check so GraphQL errors surface with context\nlet remaining = client.rate_limit_remaining().await?;\nanyhow::ensure!(remaining > 0, \"GitHub GraphQL rate limit exhausted\");\nlet prs = client.pull_request_node_id(owner, repo, number).await?;","handlingStrategy":"try-catch","validationCode":"// Rust: pre-check inputs and rate limit before the GraphQL call\nanyhow::ensure!(!owner.is_empty() && !repo.is_empty(), \"owner/repo required\");\n// optionally: ensure!(client.rate_limit_remaining().await? > 0, \"GraphQL rate limit exhausted\");","typeGuard":null,"tryCatchPattern":"match client.pull_request_node_id(owner, repo, number).await {\n    Ok(id) => use(id),\n    Err(e) if e.to_string().contains(\"RATE_LIMITED\") => schedule_retry_after_reset(),\n    Err(e) if e.to_string().contains(\"NOT_FOUND\") => handle_missing_pr(),\n    Err(e) => log_and_surface(e),\n}","preventionTips":["Check GraphQL rate-limit budget before batch queries.","Verify tokens have the scopes needed for every field in the query.","Keep the GraphQL query strings in sync with the GitHub schema.","Validate owner/repo/PR numbers before querying."],"tags":["github","graphql","api","network"],"backgroundTag":"upstream-api-error","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}