jesseduffield/lazygit · warning

GraphQL query failed with status: %s. Body: %s

Error message

GraphQL query failed with status: %s. Body: %s

What it means

The GitHub integration sends a GraphQL query (pull requests for the current repo) with a 10-second HTTP timeout; any non-200 response is turned into this error including the HTTP status and response body. Because the data is auxiliary, lazygit surfaces it but recovers on the next PR refresh rather than crashing.

Source

Thrown at pkg/commands/git_commands/github.go:292

	}

	req.Header.Set("Authorization", "token "+token)
	req.Header.Set("Content-Type", "application/json")

	// Bound the request so that a dead or extremely slow network can't leave
	// the pull-request refresh in flight for minutes. The data is auxiliary,
	// so giving up and retrying on the next refresh beats waiting.
	client := &http.Client{Timeout: 10 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		bodyStr := new(bytes.Buffer)
		_, _ = bodyStr.ReadFrom(resp.Body)
		return nil, fmt.Errorf("GraphQL query failed with status: %s. Body: %s", resp.Status, bodyStr.String())
	}

	respBytes, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	return parsePullRequestsResponse(respBytes)
}

func parsePullRequestsResponse(respBytes []byte) ([]*models.GithubPullRequest, error) {
	var result Response
	if err := json.Unmarshal(respBytes, &result); err != nil {
		return nil, err
	}

	prs := []*models.GithubPullRequest{}
	for _, repoQuery := range result.Data.Repository {

View on GitHub (pinned to c477a2959b)

Solutions

  1. Read the embedded body: it states the cause (rate limit reset time, 'Bad credentials', etc.).
  2. For 401, re-authenticate: remove the stored token (config/credentials) and let lazygit re-do the OAuth flow.
  3. For 403/429, wait for the rate-limit window to reset; reduce refresh frequency.
  4. For 5xx/proxy issues, verify with 'curl -H "Authorization: bearer <token>" https://api.github.com/graphql' from the same network.
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check auth/rate-limit cheaply before the GraphQL call:
resp, err := http.Get("https://api.github.com/rate_limit") // with auth header
if err == nil && resp.StatusCode == 401 {
    return errors.New("token invalid; re-authenticate")
}
_ = resp.Body.Close()

Try / catch

if err != nil {
    var sb strings.Builder
    if strings.Contains(err.Error(), "GraphQL query failed with status:") {
        // auxiliary data: log and continue; next PR refresh retries
        log.Warn(err)
        return nil, err // non-fatal at UI layer
    }
    return err
}

Prevention

When it happens

Trigger: HTTP 401 (bad/expired stored GitHub token), 403/429 rate limiting, 5xx GitHub outages, or a proxy returning an error page — any non-OK status from api.github.com/graphql.

Common situations: Overusing the PR view beyond GitHub's API quota; a revoked OAuth token after re-authenticating elsewhere; corporate proxies injecting error bodies; GitHub incidents.

Related errors


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/f2be52a8fd3f758f. Report an issue: GitHub.