{"record":{"id":"efab66ff4d8169ee","repo":"grpc-ecosystem/grpc-gateway","slug":"s-tags-w","errorCode":null,"errorMessage":"%s: tags: %w","messagePattern":"(.+?): tags: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"openapiv3-merge/internal/merge/merge.go","lineNumber":236,"sourceCode":"\t\tcase \"webhooks\":\n\t\t\tobj, err := decodeOrderedObject(raw)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"%s: webhooks: %w\", in.Name, err)\n\t\t\t}\n\t\t\td.Webhooks = obj\n\t\tcase \"components\":\n\t\t\tif !isJSONNull(raw) {\n\t\t\t\tif err := json.Unmarshal(raw, d.Components); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"%s: components: %w\", in.Name, err)\n\t\t\t\t}\n\t\t\t}\n\t\tcase \"security\":\n\t\t\tif err := json.Unmarshal(raw, &d.Security); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"%s: security: %w\", in.Name, err)\n\t\t\t}\n\t\tcase \"tags\":\n\t\t\tif err := json.Unmarshal(raw, &d.Tags); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"%s: tags: %w\", in.Name, err)\n\t\t\t}\n\t\tcase \"externalDocs\":\n\t\t\td.ExternalDocs = raw\n\t\tdefault:\n\t\t\td.extras.set(key, raw)\n\t\t}\n\t}\n\tif _, err := dec.Token(); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", in.Name, err)\n\t}\n\tif d.OpenAPI == \"\" {\n\t\treturn nil, fmt.Errorf(\"%s: missing required field \\\"openapi\\\"\", in.Name)\n\t}\n\tif isJSONNull(d.Info) {\n\t\treturn nil, fmt.Errorf(\"%s: missing required field \\\"info\\\"\", in.Name)\n\t}\n\treturn d, nil\n}","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/grpc-ecosystem/grpc-gateway/blob/a58a4436a376a4bcc7d8f10c4d4f919a8438bba9/openapiv3-merge/internal/merge/merge.go#L218-L254","documentation":"This error is produced while parse() unmarshals the top-level `tags` array of an OpenAPI document into []json.RawMessage. It wraps the underlying encoding/json error with the input document's name, so you know which file had a malformed `tags` field. The library throws it because `tags` must be a JSON array; any other shape fails to unmarshal.","triggerScenarios":"Calling Merge with an Input whose Data contains a top-level \"tags\" key whose value is not a JSON array (e.g. \"tags\": {} or \"tags\": \"foo\"), or contains entries that are not JSON values decodable by encoding/json.","commonSituations":"Hand-edited OpenAPI files, a code generator emitting tags as an object instead of an array, templating/config substitution corrupting the JSON, or YAML-to-JSON conversion producing the wrong shape for tags.","solutions":["Open the named input file and verify the top-level \"tags\" value is a JSON array of objects","Run the file through a JSON linter/parser to pinpoint the syntax or type error","Regenerate the document from its source (e.g. protoc) if it was produced by a generator","Fix any templating or conversion step that rewrites the tags section"],"exampleFix":"// before\n\"tags\": { \"name\": \"pets\" }\n// after\n\"tags\": [ { \"name\": \"pets\" } ]","handlingStrategy":"validation","validationCode":"func tagsIsArray(data []byte) error {\n\tvar doc map[string]json.RawMessage\n\tif err := json.Unmarshal(data, &doc); err != nil { return err }\n\traw, ok := doc[\"tags\"]\n\tif !ok { return nil }\n\tvar tags []json.RawMessage\n\treturn json.Unmarshal(raw, &tags)\n}","typeGuard":"func isArray(raw json.RawMessage) bool {\n\tvar arr []json.RawMessage\n\treturn json.Unmarshal(raw, &arr) == nil\n}","tryCatchPattern":"merged, err := merge.Merge(inputs)\nif err != nil {\n\tvar tagErr *merge.TagError\n\tif errors.As(err, &tagErr) { /* handle malformed tags for tagErr.Name */ }\n\treturn fmt.Errorf(\"merge failed: %w\", err)\n}","preventionTips":["Lint every input with a strict OpenAPI 3.1 validator before merging","Keep \"tags\" as an array of objects per the spec; never hand-edit generated JSON without re-validating","Add a CI step that parses each spec with encoding/json or jq before merge jobs"],"tags":["json","openapi","parsing"],"backgroundTag":"json-unmarshal-type-error","analyzedSha":"a58a4436a376a4bcc7d8f10c4d4f919a8438bba9","analyzedAt":"2026-09-02T10:28:31.537Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}