{"record":{"id":"0530cff2425b4640","repo":"github/github-mcp-server","slug":"failed-to-query-issue-fields-metadata-w","errorCode":null,"errorMessage":"failed to query issue fields metadata: %w","messagePattern":"failed to query issue fields metadata: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/issues.go","lineNumber":315,"sourceCode":"\t\t})\n\t}\n\n\treturn issueFields, nil\n}\n\nfunc resolveIssueRequestFieldValues(ctx context.Context, gqlClient *githubv4.Client, owner, repo string, issueFields []issueWriteFieldInput) ([]*github.IssueRequestFieldValue, []int64, error) {\n\tif len(issueFields) == 0 {\n\t\treturn nil, nil, nil\n\t}\n\n\tctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, \"issue_fields\", \"repo_issue_fields\")\n\tvar query issueFieldWriteMetadataQuery\n\tvars := map[string]any{\n\t\t\"owner\": githubv4.String(owner),\n\t\t\"repo\":  githubv4.String(repo),\n\t}\n\tif err := gqlClient.Query(ctxWithFeatures, &query, vars); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to query issue fields metadata: %w\", err)\n\t}\n\n\t// Build name → node map, dispatching on concrete type to extract name.\n\tfieldByName := make(map[string]issueFieldWriteMetadataNode, len(query.Repository.IssueFields.Nodes))\n\tfor _, node := range query.Repository.IssueFields.Nodes {\n\t\tvar name string\n\t\tswitch string(node.TypeName) {\n\t\tcase \"IssueFieldText\":\n\t\t\tname = string(node.IssueFieldText.Name)\n\t\tcase \"IssueFieldNumber\":\n\t\t\tname = string(node.IssueFieldNumber.Name)\n\t\tcase \"IssueFieldDate\":\n\t\t\tname = string(node.IssueFieldDate.Name)\n\t\tcase \"IssueFieldSingleSelect\":\n\t\t\tname = string(node.IssueFieldSingleSelect.Name)\n\t\tdefault:\n\t\t\tcontinue\n\t\t}","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/issues.go#L297-L333","documentation":"resolveIssueRequestFieldValues (pkg/github/issues.go:315) runs a GraphQL metadata query to map issue_fields names to database IDs before an issue write. The query runs under preview feature context ghcontext.WithGraphQLFeatures(ctx, \"issue_fields\", \"repo_issue_fields\"). This error means that GraphQL query failed: preview not available to the token/repo, auth failure, rate limit, or a transport error.","triggerScenarios":"update_issue/create_issue with issue_fields where the repository or token cannot use the issue-fields preview (GitHub returns an error for the previewed selection), 401 bad credentials, GraphQL rate limit exhausted, GHES without issue-fields support, or network failure to the GraphQL endpoint.","commonSituations":"Orgs/repos where issue fields are not enabled or not rolled out; tokens (fine-grained PATs, GitHub Apps) without the preview; older GHES; scripts burning GraphQL quota; the token can use REST fine but GraphQL fails on previewed fields.","solutions":["Confirm issue fields are actually configured on the repository (repo Settings → Issues → fields)","Test the token against the GraphQL endpoint directly with a trivial query to separate auth/preview from network issues","Wait out the GraphQL rate limit if exhausted (check x-ratelimit-remaining)","On GHES, verify the version supports issue fields and the GraphQL host is configured"],"exampleFix":"# before\nupdate_issue {\"issue_fields\": [...]} on a repo with no issue fields configured\n\n# after\n# configure fields in repo settings first, then:\nupdate_issue {\"issue_fields\": [{\"field_name\": \"Priority\", \"field_option_name\": \"P0\"}]}","handlingStrategy":"try-catch","validationCode":"// smoke-test the token's access to the previewed metadata before batch updates\nvar probe struct {\n    Repository struct {\n        IssueFields struct{ Nodes []struct{ TypeName string `json:\"__typename\"` } } `graphql:\"issueFields(first: 1)\"` // adjust to actual probe shape\n    } `graphql:\"repository(owner: $owner, name: $repo)\"`\n}\nif err := gqlClient.Query(ghcontext.WithGraphQLFeatures(ctx, \"issue_fields\", \"repo_issue_fields\"), &probe, vars); err != nil {\n    return fmt.Errorf(\"issue fields unavailable for this token/repo: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := gqlClient.Query(ctxWithFeatures, &query, vars); err != nil {\n    msg := err.Error()\n    switch {\n    case strings.Contains(msg, \"Bad credentials\"):\n        return fmt.Errorf(\"invalid token\")\n    case strings.Contains(msg, \"rate limit\"):\n        time.Sleep(waitForReset())\n        return retry()\n    case strings.Contains(msg, \"Could not resolve to\"):\n        return fmt.Errorf(\"repository %s/%s not visible\", owner, repo)\n    }\n    return fmt.Errorf(\"issue fields not supported here (preview/GHES?): %w\", err)\n}","preventionTips":["Gate issue_fields usage on the repo actually having fields configured","Keep one proven-good payload per repo as a canary before bulk runs","Track GraphQL rate-limit headers in long scripts and throttle before hitting limits"],"tags":["go","graphql","issue-fields","auth","rate-limit"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}