github/github-mcp-server · error
failed to get issue ID: %w
Error message
failed to get issue ID: %w
What it means
getIssueID (pkg/github/issues.go:78) translates an issue number into a GraphQL node ID via repository(owner:,name:){ issue(number:){ id } }. This error means the GraphQL query itself failed: GitHub returned a GraphQL error payload ('Could not resolve to an Issue with the number of N', bad credentials, rate limit exceeded) or the transport failed. It fires before any issue mutation, when only the main issue ID is needed.
Source
Thrown at pkg/github/issues.go:78
// Build query variables common to both cases
vars := map[string]any{
"owner": githubv4.String(owner),
"repo": githubv4.String(repo),
"issueNumber": githubv4.Int(issueNumber), // #nosec G115 - issue numbers are always small positive integers
}
if duplicateOf == 0 {
// Only fetch the main issue ID
var query struct {
Repository struct {
Issue struct {
ID githubv4.ID
} `graphql:"issue(number: $issueNumber)"`
} `graphql:"repository(owner: $owner, name: $repo)"`
}
if err := gqlClient.Query(ctx, &query, vars); err != nil {
return "", "", fmt.Errorf("failed to get issue ID: %w", err)
}
return query.Repository.Issue.ID, "", nil
}
// Fetch both issue IDs in a single query
var query struct {
Repository struct {
Issue struct {
ID githubv4.ID
} `graphql:"issue(number: $issueNumber)"`
DuplicateIssue struct {
ID githubv4.ID
} `graphql:"duplicateIssue: issue(number: $duplicateOf)"`
} `graphql:"repository(owner: $owner, name: $repo)"`
}
// Add duplicate issue number to variablesView on GitHub (pinned to 0ea1f775a7)
Solutions
- Verify the issue exists first with a cheap REST call: GET /repos/{owner}/{repo}/issues/{number}
- Check token validity and that it can read the repo (repo scope for private repos, correct fine-grained repo access)
- Check GraphQL rate limit (POST /graphql returns remaining points in headers) and wait if exhausted
- For GHES, verify the GitHub API host configuration so the GraphQL endpoint resolves and is reachable
Example fix
// before
updateIssue(ctx, client, gqlClient, owner, repo, 4242, ...) // 4242 does not exist
// after
if _, _, err := client.Issues.Get(ctx, owner, repo, 4242); err != nil {
return fmt.Errorf("issue does not exist or is not visible: %w", err)
}
updateIssue(ctx, client, gqlClient, owner, repo, 4242, ...) Defensive patterns
Strategy: try-catch
Validate before calling
if issueNumber <= 0 {
return fmt.Errorf("issue number must be positive")
}
if _, resp, err := client.Issues.Get(ctx, owner, repo, issueNumber); err != nil {
return fmt.Errorf("pre-check failed, issue may not exist: %w", err)
} else {
_ = resp.Body.Close()
} Try / catch
if err := gqlClient.Query(ctx, &query, vars); err != nil {
msg := err.Error()
switch {
case strings.Contains(msg, "Could not resolve to an Issue"):
return fmt.Errorf("issue #%d not found in %s/%s", issueNumber, owner, repo)
case strings.Contains(msg, "Bad credentials"):
return fmt.Errorf("token invalid or expired")
case strings.Contains(msg, "rate limit"):
time.Sleep(waitForReset()) // then retry once
return gqlClient.Query(ctx, &query, vars)
default:
return err
}
} Prevention
- Pre-check issue existence with the cheap REST call before GraphQL-ID-dependent operations
- Keep tokens fresh and scoped to the target repos
- Budget GraphQL calls in bulk scripts; the points cost of issue(number:) queries adds up
When it happens
Trigger: Calling update_issue paths where the issue number does not exist in owner/repo (or is private and the token lacks access); expired/insufficient token (401); GraphQL rate limit exhausted; GHES api host configured without a working GraphQL endpoint; network failure to the GraphQL URL.
Common situations: Automations passing a wrong or stale issue number; fine-grained PATs or GitHub App tokens without access to the target repo; GHES deployments where the REST host works but the GraphQL host/URL is wrong; heavy scripting hitting the 5,000 points/hour GraphQL budget.
Related errors
- failed to query issue fields metadata: %w
- failed to get issue: %w
- failed to fetch raw content: %s
- %s: %w
- failed to fetch existing issue field values: %w
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/85ca71b8dc47bb0c.
Report an issue: GitHub.