{"record":{"id":"444437cce620d313","repo":"micro/go-micro","slug":"unrecognized-message-type-v-444437","errorCode":null,"errorMessage":"unrecognized message type: %v","messagePattern":"unrecognized message type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"codec/protorpc/protorpc.go","lineNumber":117,"sourceCode":"\t\t\treturn err\n\t\t}\n\t\tif flusher, ok := c.rwc.(flusher); ok {\n\t\t\tif err = flusher.Flush(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\tcase codec.Event:\n\t\tm, ok := b.(proto.Message)\n\t\tif !ok {\n\t\t\treturn codec.ErrInvalidMessage\n\t\t}\n\t\tdata, err := proto.Marshal(m)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, _ = c.rwc.Write(data)\n\tdefault:\n\t\treturn fmt.Errorf(\"unrecognized message type: %v\", m.Type)\n\t}\n\treturn nil\n}\n\nfunc (c *protoCodec) ReadHeader(m *codec.Message, mt codec.MessageType) error {\n\tc.buf.Reset()\n\tc.mt = mt\n\n\tswitch mt {\n\tcase codec.Request:\n\t\tdata, err := ReadNetString(c.rwc)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\trtmp := new(Request)\n\t\terr = proto.Unmarshal(data, rtmp)\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/codec/protorpc/protorpc.go#L99-L135","documentation":"protoCodec.Write only serializes messages whose Type is Request, Response, Error, or Event. Any other codec.MessageType on the outgoing message hits the default branch and returns this error. It guards the protobuf-rpc write path against unknown or zero-valued message types.","triggerScenarios":"Calling protoCodec.Write (directly or via a transport) with an m.Type outside {Request, Response, Error, Event}, e.g. the zero value of codec.MessageType or a custom type.","commonSituations":"Hand-rolled transports or middleware that construct codec.Message structs without setting Type; a newly introduced MessageType not yet handled by protorpc; copying message structs and losing the type field.","solutions":["Set m.Type to a supported value (codec.Request, codec.Response, codec.Error, or codec.Event) before calling Write","For broadcast/publish use codec.Event, which marshals b as a proto.Message and writes it raw","Verify your transport layer is not resetting m.Type when wrapping messages","Update go-micro if a new MessageType was added after your pinned version"],"exampleFix":"// before\nm := &codec.Message{}\nc.Write(m, payload) // unrecognized message type: 0\n// after\nm := &codec.Message{Type: codec.Request}\nc.Write(m, payload)","handlingStrategy":"validation","validationCode":"if m.Type != codec.Request && m.Type != codec.Response && m.Type != codec.Error && m.Type != codec.Event {\n    return fmt.Errorf(\"cannot write message type %v via protorpc\", m.Type)\n}","typeGuard":"func isWritableType(t codec.MessageType) bool {\n    return t == codec.Request || t == codec.Response || t == codec.Error || t == codec.Event\n}","tryCatchPattern":null,"preventionTips":["Always set Type explicitly when constructing codec.Message","Use codec.Event for publishes and codec.Request for client calls","Remember protorpc requires body values implementing proto.Message (else codec.ErrInvalidMessage)"],"tags":["codec","protorpc","protobuf","invalid-argument"],"backgroundTag":"unsupported-codec-message-type","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}