gitbutlerapp/gitbutler · error · anyhow::Error
GitHub GraphQL returned errors: {messages}
Error message
GitHub GraphQL returned errors: {messages} What it means
The GraphQL response contained a top-level `errors` array; but-github joins the error messages with '; ' and fails. This is how every GraphQL-level refusal surfaces: insufficient scopes, invalid variables, failed preconditions (e.g. NOT_READY_FOR_AUTO_MERGE), or rate-limit messages.
Source
Thrown at crates/but-github/src/client.rs:1300
struct GraphQlError {
message: String,
}
#[derive(Deserialize)]
struct GraphQlResponse {
data: Option<serde_json::Value>,
errors: Option<Vec<GraphQlError>>,
}
let payload: GraphQlResponse = serde_json::from_slice(body)?;
if let Some(errors) = payload.errors {
let messages = errors
.into_iter()
.map(|error| error.message)
.collect::<Vec<_>>()
.join("; ");
bail!("GitHub GraphQL returned errors: {messages}");
}
let Some(data) = payload.data else {
bail!("GitHub GraphQL response did not include data");
};
Ok(serde_json::from_value(data)?)
}
pub struct PullRequestNodeId {
id: String,
}
impl PullRequestNodeId {
pub fn from_string(value: String) -> Self {
PullRequestNodeId { id: value }
}
}View on GitHub (pinned to caf1f223d3)
Solutions
- Read the joined message(s) - they carry the exact GraphQL error type
- Fix the named precondition (PR state, repo settings, scopes) and retry
- If scope-related, re-authenticate so the token gains the needed scopes
Defensive patterns
Strategy: try-catch
Try / catch
match client.graphql_query(query, &vars).await {
Err(e) if e.to_string().starts_with("GitHub GraphQL returned errors:") => {
let msg = e.to_string();
if msg.contains("rate limit") { backoff_and_retry().await } else { Err(e) }
}
other => other?,
} Prevention
- Read the joined messages - they name the exact GraphQL error type
- Verify PR preconditions before mutations
- Ensure the token carries the scopes the query or mutation needs
When it happens
Trigger: Mutating a PR that fails a precondition; a token missing the required OAuth scopes; querying fields the token cannot see; variable type mismatches in the query.
Common situations: Enabling auto-merge before required checks pass; read-scoped tokens used for writes; GitHub API version drift on GitHub Enterprise Server.
Related errors
- GitHub GraphQL repository not found for {owner}/{repo}
- GitHub GraphQL enablePullRequestAutoMerge returned an empty
- GitHub GraphQL disablePullRequestAutoMerge returned an empty
- GitHub GraphQL pull request #{pr_number} not found for {owne
- GitHub GraphQL pull request #{pr_number} in {owner}/{repo} r
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/fe801c9f7dc47a95.
Report an issue: GitHub.