{"record":{"id":"5d56b437096708ea","repo":"github/github-mcp-server","slug":"failed-to-update-issue-with-agent-assignment-w","errorCode":null,"errorMessage":"failed to update issue with agent assignment: %w","messagePattern":"failed to update issue with agent assignment: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/copilot.go","lineNumber":360,"sourceCode":"\n\t\t\t// Add the GraphQL-Features header for the agent assignment API\n\t\t\t// The header will be read by the HTTP transport if it's configured to do so\n\t\t\tctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, \"issues_copilot_assignment_api_support\")\n\n\t\t\t// Capture the time before assignment to filter out older PRs during polling\n\t\t\tassignmentTime := time.Now().UTC()\n\n\t\t\tif err := client.Mutate(\n\t\t\t\tctxWithFeatures,\n\t\t\t\t&updateIssueMutation,\n\t\t\t\tUpdateIssueInput{\n\t\t\t\t\tID:              getIssueQuery.Repository.Issue.ID,\n\t\t\t\t\tAssigneeIDs:     actorIDs,\n\t\t\t\t\tAgentAssignment: agentAssignment,\n\t\t\t\t},\n\t\t\t\tnil,\n\t\t\t); err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to update issue with agent assignment: %w\", err)\n\t\t\t}\n\n\t\t\t// Poll for a linked PR created by Copilot after the assignment\n\t\t\tpollConfig := getPollConfig(ctx)\n\n\t\t\t// Get progress token from request for sending progress notifications\n\t\t\tprogressToken := request.Params.GetProgressToken()\n\n\t\t\t// Send initial progress notification that assignment succeeded and polling is starting\n\t\t\tif progressToken != nil && request.Session != nil && pollConfig.MaxAttempts > 0 {\n\t\t\t\t_ = request.Session.NotifyProgress(ctx, &mcp.ProgressNotificationParams{\n\t\t\t\t\tProgressToken: progressToken,\n\t\t\t\t\tProgress:      0,\n\t\t\t\t\tTotal:         float64(pollConfig.MaxAttempts),\n\t\t\t\t\tMessage:       \"Copilot assigned to issue, waiting for PR creation...\",\n\t\t\t\t})\n\t\t\t}\n","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/copilot.go#L342-L378","documentation":"The GraphQL updateIssue mutation carrying AssigneeIDs (the copilot-swe-agent bot) and the AgentAssignment input failed during assign_copilot_to_issue. The mutation runs on a context tagged with the issues_copilot_assignment_api_support feature so GitHub can gate the private AgentAssignment field; GitHub rejects it when the feature is unavailable, Copilot is not enabled, or the token lacks permission. This is a server-side rejection of the assignment, after the suggested-actor lookup already succeeded.","triggerScenarios":"Calling assign_copilot_to_issue on a repo/org where the Copilot coding agent (cloud agent) is disabled, with a token lacking write/issue-assign permission, on a GitHub instance whose schema does not accept the AgentAssignment input (feature flag not honored), or when the issue cannot accept agent assignment (locked, archived repo).","commonSituations":"Org policy disabling Copilot coding agent, fine-grained PAT without Issues:write, GHES version predating agent assignment API, race where the issue was closed between lookup and mutation.","solutions":["Enable the Copilot coding agent for the repository/org (docs.github.com Copilot cloud-agent) and retry","Use a PAT or GitHub App token with write access to issues in that repository","Check the wrapped GraphQL error message for FORBIDDEN/NOT_FOUND to distinguish permissions from feature unavailability","Verify the issue is open and the repo is not archived, then retry"],"exampleFix":"// before\nif err := client.Mutate(ctxWithFeatures, &updateIssueMutation, input, nil); err != nil {\n\treturn nil, nil, fmt.Errorf(\"failed to update issue with agent assignment: %w\", err)\n}\n\n// after — classify the GraphQL rejection for the caller\nif err := client.Mutate(ctxWithFeatures, &updateIssueMutation, input, nil); err != nil {\n\tmsg := err.Error()\n\tif strings.Contains(msg, \"FORBIDDEN\") {\n\t\treturn utils.NewToolResultError(\"copilot assignment denied: enable the Copilot coding agent and use a token with issue write access\"), nil, nil\n\t}\n\treturn nil, nil, fmt.Errorf(\"failed to update issue with agent assignment: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// pre-flight: confirm Copilot agent availability before assigning\ncopilotActor, err := findCopilotSuggestedActor(ctx, client, owner, repo)\nif err != nil {\n\treturn err // suggested-actors query itself failed\n}\nif copilotActor == nil {\n\treturn errors.New(\"copilot is not available as an assignee for this repo — enable the Copilot coding agent first\")\n}","typeGuard":null,"tryCatchPattern":"if err := client.Mutate(ctxWithFeatures, &updateIssueMutation, input, nil); err != nil {\n\tmsg := err.Error()\n\tswitch {\n\tcase strings.Contains(msg, \"FORBIDDEN\"):\n\t\t// permissions/Copilot disabled — surface actionable guidance, no retry\n\tcase strings.Contains(msg, \"NOT_FOUND\"):\n\t\t// stale issue/repo — refetch and optionally retry once\n\tdefault:\n\t\treturn fmt.Errorf(\"failed to update issue with agent assignment: %w\", err)\n\t}\n}","preventionTips":["Enable the Copilot coding agent org-wide before building automation around assignment","Use tokens with issue write permission for assignment workflows","Check suggested actors first — the code already degrades gracefully when copilot is absent","Keep GitHub App permissions (issues:write) in sync when the assignment feature rolls out"],"tags":["graphql","copilot","permissions","issues","github-api"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}