gitbutlerapp/gitbutler · error

GitHub GraphQL response did not include data

Error message

GitHub GraphQL response did not include data

What it means

The GitHub GraphQL response contained neither an `errors` array nor a `data` field, so the client has nothing to deserialize. This indicates a structurally unexpected response from GitHub — the payload shape violated the GraphQL contract this client expects.

Solutions

  1. Log the raw response body before parsing to see what GitHub actually returned.
  2. Check the GitHub status page for incidents affecting the GraphQL API.
  3. Retry the request once — transient gateway issues often produce empty payloads.
  4. Verify the client's GraphQL response struct still matches the current GitHub GraphQL schema.
  5. Ensure no middleware/proxy is stripping or rewriting the response body.
Defensive patterns

Strategy: retry

Try / catch

match client.call().await {
    Ok(v) => v,
    Err(e) if e.to_string().contains("did not include data") => {
        tokio::time::sleep(Duration::from_secs(2)).await;
        retry_with_backoff(3).await // transient gateway/empty-body issue
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: A GraphQL call in but-github's client where the parsed payload has `errors: null` and `data: null` — e.g. a proxy or gateway returning an empty/invalid JSON body, or a schema/type mismatch deserializing the response envelope.

Common situations: Corporate proxies or GitHub incident/degraded states returning empty 200 responses; an API preview or schema change removing the expected field; a bug where the response was consumed before parsing.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/42578707642b2228. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-github/src/client.rs:1856

    #[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 }
    }
}

impl Serialize for PullRequestNodeId {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where

View on GitHub (pinned to 58e5313667)