{"record":{"id":"45eed58ca4aa2f4e","repo":"github/github-mcp-server","slug":"duplicate-of-must-be-provided-when-state-reason-is","errorCode":null,"errorMessage":"duplicate_of must be provided when state_reason is 'duplicate'","messagePattern":"duplicate_of must be provided when state_reason is 'duplicate'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/issues.go","lineNumber":2731,"sourceCode":"\t}\n\n\t// Return minimal response with just essential information\n\tminimalResponse := MinimalResponse{\n\t\tID:  fmt.Sprintf(\"%d\", updatedIssue.GetID()),\n\t\tURL: updatedIssue.GetHTMLURL(),\n\t}\n\n\tr, err := json.Marshal(minimalResponse)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal response: %w\", err)\n\t}\n\n\treturn utils.NewToolResultText(string(r)), nil\n}\n\nfunc validateDuplicateState(state, stateReason string, duplicateOf int) error {\n\tif state == \"closed\" && stateReason == \"duplicate\" && duplicateOf == 0 {\n\t\treturn fmt.Errorf(\"duplicate_of must be provided when state_reason is 'duplicate'\")\n\t}\n\treturn nil\n}\n\ntype updateIssueRequestWithNullableType struct {\n\tgithub.UpdateIssueRequest\n\tType *string `json:\"type\"`\n}\n\nfunc patchIssue(ctx context.Context, client *github.Client, owner, repo string, issueNumber int, issueRequest github.UpdateIssueRequest, issueType string, issueTypeProvided bool) (*github.Issue, *github.Response, error) {\n\tif !issueTypeProvided || issueType != \"\" {\n\t\treturn client.Issues.Update(ctx, owner, repo, issueNumber, issueRequest)\n\t}\n\n\tapiURL := fmt.Sprintf(\"repos/%s/%s/issues/%d\", owner, repo, issueNumber)\n\tbody := &updateIssueRequestWithNullableType{UpdateIssueRequest: issueRequest}\n\treq, err := client.NewRequest(ctx, http.MethodPatch, apiURL, body)\n\tif err != nil {","sourceCodeStart":2713,"sourceCodeEnd":2749,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/issues.go#L2713-L2749","documentation":"validateDuplicateState rejects an update_issue call that closes an issue with state_reason=\"duplicate\" but omits the duplicate_of parameter. GitHub requires a duplicate to reference the canonical issue, so the server enforces this before calling the API.","triggerScenarios":"Calling update_issue with {\"state\":\"closed\",\"state_reason\":\"duplicate\"} and no duplicate_of (or duplicate_of: 0).","commonSituations":"An LLM or script copies the close-as-duplicate flow but forgets the canonical issue number; passing duplicate_of as a string instead of a number so it decodes to zero.","solutions":["Add duplicate_of with the issue number of the canonical (original) issue to the update_issue arguments","If you did not mean to mark it a duplicate, use state_reason \"not_planned\" or omit state_reason entirely","Ensure duplicate_of is passed as a JSON number, not a string"],"exampleFix":"// before\n{\"owner\":\"octo\",\"repo\":\"kit\",\"issue_number\":42,\"state\":\"closed\",\"state_reason\":\"duplicate\"}\n// after\n{\"owner\":\"octo\",\"repo\":\"kit\",\"issue_number\":42,\"state\":\"closed\",\"state_reason\":\"duplicate\",\"duplicate_of\":7}","handlingStrategy":"validation","validationCode":"func validateDuplicateClose(args map[string]any) error {\n\tstate, _ := args[\"state\"].(string)\n\treason, _ := args[\"state_reason\"].(string)\n\tif state == \"closed\" && reason == \"duplicate\" {\n\t\tdup, ok := args[\"duplicate_of\"]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"duplicate_of is required when closing as duplicate\")\n\t\t}\n\t\tif n, ok := dup.(float64); !ok || n <= 0 {\n\t\t\treturn fmt.Errorf(\"duplicate_of must be a positive issue number\")\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func hasValidDuplicateOf(args map[string]any) bool {\n\tif args[\"state\"] != \"closed\" || args[\"state_reason\"] != \"duplicate\" {\n\t\treturn true\n\t}\n\tn, ok := args[\"duplicate_of\"].(float64)\n\treturn ok && n > 0 && n == float64(int(n))\n}","tryCatchPattern":null,"preventionTips":["Always pair state_reason:'duplicate' with duplicate_of in update_issue templates","Send duplicate_of as a JSON number referencing the canonical issue"],"tags":["validation","issues","duplicate","update-issue"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}