{"record":{"id":"85ca71b8dc47bb0c","repo":"github/github-mcp-server","slug":"failed-to-get-issue-id-w","errorCode":null,"errorMessage":"failed to get issue ID: %w","messagePattern":"failed to get issue ID: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/issues.go","lineNumber":78,"sourceCode":"\t// Build query variables common to both cases\n\tvars := map[string]any{\n\t\t\"owner\":       githubv4.String(owner),\n\t\t\"repo\":        githubv4.String(repo),\n\t\t\"issueNumber\": githubv4.Int(issueNumber), // #nosec G115 - issue numbers are always small positive integers\n\t}\n\n\tif duplicateOf == 0 {\n\t\t// Only fetch the main issue ID\n\t\tvar query struct {\n\t\t\tRepository struct {\n\t\t\t\tIssue struct {\n\t\t\t\t\tID githubv4.ID\n\t\t\t\t} `graphql:\"issue(number: $issueNumber)\"`\n\t\t\t} `graphql:\"repository(owner: $owner, name: $repo)\"`\n\t\t}\n\n\t\tif err := gqlClient.Query(ctx, &query, vars); err != nil {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"failed to get issue ID: %w\", err)\n\t\t}\n\n\t\treturn query.Repository.Issue.ID, \"\", nil\n\t}\n\n\t// Fetch both issue IDs in a single query\n\tvar query struct {\n\t\tRepository struct {\n\t\t\tIssue struct {\n\t\t\t\tID githubv4.ID\n\t\t\t} `graphql:\"issue(number: $issueNumber)\"`\n\t\t\tDuplicateIssue struct {\n\t\t\t\tID githubv4.ID\n\t\t\t} `graphql:\"duplicateIssue: issue(number: $duplicateOf)\"`\n\t\t} `graphql:\"repository(owner: $owner, name: $repo)\"`\n\t}\n\n\t// Add duplicate issue number to variables","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/issues.go#L60-L96","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nupdateIssue(ctx, client, gqlClient, owner, repo, 4242, ...) // 4242 does not exist\n\n// after\nif _, _, err := client.Issues.Get(ctx, owner, repo, 4242); err != nil {\n    return fmt.Errorf(\"issue does not exist or is not visible: %w\", err)\n}\nupdateIssue(ctx, client, gqlClient, owner, repo, 4242, ...)","handlingStrategy":"try-catch","validationCode":"if issueNumber <= 0 {\n    return fmt.Errorf(\"issue number must be positive\")\n}\nif _, resp, err := client.Issues.Get(ctx, owner, repo, issueNumber); err != nil {\n    return fmt.Errorf(\"pre-check failed, issue may not exist: %w\", err)\n} else {\n    _ = resp.Body.Close()\n}","typeGuard":null,"tryCatchPattern":"if err := gqlClient.Query(ctx, &query, vars); err != nil {\n    msg := err.Error()\n    switch {\n    case strings.Contains(msg, \"Could not resolve to an Issue\"):\n        return fmt.Errorf(\"issue #%d not found in %s/%s\", issueNumber, owner, repo)\n    case strings.Contains(msg, \"Bad credentials\"):\n        return fmt.Errorf(\"token invalid or expired\")\n    case strings.Contains(msg, \"rate limit\"):\n        time.Sleep(waitForReset()) // then retry once\n        return gqlClient.Query(ctx, &query, vars)\n    default:\n        return err\n    }\n}","preventionTips":["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"],"tags":["go","graphql","github-api","auth","rate-limit"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}