{"record":{"id":"e7e7e0ef7823e3c5","repo":"github/github-mcp-server","slug":"each-issue-fields-item-must-be-an-object","errorCode":null,"errorMessage":"each issue_fields item must be an object","messagePattern":"each issue_fields item must be an object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/issues.go","lineNumber":246,"sourceCode":"\tTextValue struct {\n\t\tField IssueFieldRef\n\t\tValue githubv4.String\n\t} `graphql:\"... on IssueFieldTextValue\"`\n}\n\nfunc optionalIssueWriteFields(args map[string]any) ([]issueWriteFieldInput, error) {\n\tissueFieldsRaw, exists := args[\"issue_fields\"]\n\tif !exists {\n\t\treturn nil, nil\n\t}\n\n\tvar inputMaps []map[string]any\n\tswitch v := issueFieldsRaw.(type) {\n\tcase []any:\n\t\tfor _, item := range v {\n\t\t\titemMap, ok := item.(map[string]any)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"each issue_fields item must be an object\")\n\t\t\t}\n\t\t\tinputMaps = append(inputMaps, itemMap)\n\t\t}\n\tcase []map[string]any:\n\t\tinputMaps = v\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"issue_fields must be an array\")\n\t}\n\n\tissueFields := make([]issueWriteFieldInput, 0, len(inputMaps))\n\tfor _, itemMap := range inputMaps {\n\t\tfieldName, err := RequiredParam[string](itemMap, \"field_name\")\n\t\tif err != nil || strings.TrimSpace(fieldName) == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"field_name is required for each issue_fields item\")\n\t\t}\n\n\t\tfieldOptionName, err := OptionalParam[string](itemMap, \"field_option_name\")\n\t\tif err != nil {","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/issues.go#L228-L264","documentation":"optionalIssueWriteFields (pkg/github/issues.go:246) validates the issue_fields argument of issue write tools. This error fires when issue_fields IS an array ([]any from JSON) but one of its elements is not a JSON object — e.g. a bare string, number, or nested array. Each element must be a map like {\"field_name\": ..., \"value\": ...} or {\"field_name\": ..., \"delete\": true}.","triggerScenarios":"Calling update_issue (or create_issue) with issue_fields=[\"Priority\"] or issue_fields=[\"field_name\",\"value\"] instead of issue_fields=[{\"field_name\":\"Priority\",\"value\":\"P0\"}]; also LLM-generated tool args that confuse the array-of-objects schema with array-of-strings.","commonSituations":"MCP clients/agents reformatting the schema; hand-written JSON tool payloads; passing a comma-separated string list split into tokens.","solutions":["Make every issue_fields element an object with at least field_name: [{\"field_name\":\"Priority\",\"value\":\"P0\"}]","Re-read the tool's input schema: issue_fields is an array of objects","If generating args programmatically, serialize a typed struct ([]issueWriteFieldInput) instead of hand-built any slices"],"exampleFix":"# before\n{\"issue_fields\": [\"Priority\", \"P0\"]}\n\n# after\n{\"issue_fields\": [{\"field_name\": \"Priority\", \"field_option_name\": \"P0\"}]}","handlingStrategy":"validation","validationCode":"raw, ok := args[\"issue_fields\"]\nif !ok {\n    return nil // absent is fine\n}\nitems, ok := raw.([]any)\nif !ok {\n    return errors.New(\"issue_fields must be an array\")\n}\nfor _, item := range items {\n    if _, ok := item.(map[string]any); !ok {\n        return errors.New(\"each issue_fields item must be an object\")\n    }\n}","typeGuard":"func isIssueFieldItem(v any) bool {\n    _, ok := v.(map[string]any)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Serialize tool args from a typed struct ([]IssueFieldInput) instead of hand-built map[string]any","When generating JSON args programmatically, run them through the tool's schema validator before submit","Test the happy path once against a scratch repo so shape errors surface in dev, not prod"],"tags":["go","validation","issue-fields","mcp"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}