{"record":{"id":"c7d973f003b9353d","repo":"microsoft/typescript-go","slug":"w-unknown-message-type-d","errorCode":null,"errorMessage":"%w: unknown message type: %d","messagePattern":"%w: unknown message type: (.+?)","errorType":"validation","errorClass":"ErrInvalidRequest","httpStatus":null,"severity":"error","filePath":"internal/api/protocol_msgpack.go","lineNumber":126,"sourceCode":"\tif err != nil {\n\t\treturn 0, \"\", nil, err\n\t}\n\tvar rawType byte\n\tif t <= 0x7F {\n\t\t// Positive fixint - the byte IS the value\n\t\trawType = t\n\t} else if t == msgpackU8 {\n\t\t// uint8 marker - next byte is the value\n\t\trawType, err = p.r.ReadByte()\n\t\tif err != nil {\n\t\t\treturn 0, \"\", nil, err\n\t\t}\n\t} else {\n\t\treturn 0, \"\", nil, fmt.Errorf(\"%w: expected positive fixint or uint8 marker, received: 0x%02x\", ErrInvalidRequest, t)\n\t}\n\tmsgType := MessageType(rawType)\n\tif !msgType.IsValid() {\n\t\treturn 0, \"\", nil, fmt.Errorf(\"%w: unknown message type: %d\", ErrInvalidRequest, msgType)\n\t}\n\n\t// Read method (binary)\n\tmethodBytes, err := p.readBin()\n\tif err != nil {\n\t\treturn 0, \"\", nil, err\n\t}\n\tmethod := string(methodBytes)\n\n\t// Read payload (binary)\n\tpayload, err := p.readBin()\n\tif err != nil {\n\t\treturn 0, \"\", nil, err\n\t}\n\n\treturn msgType, method, payload, nil\n}\n","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/api/protocol_msgpack.go#L108-L144","documentation":"The type integer parsed successfully but its value is outside the valid range MessageTypeRequest..MessageTypeCall (1..6); 0 is 'unknown' and values above 6 are undefined in this build. Wraps ErrInvalidRequest, making it programmatically distinguishable from transport errors.","triggerScenarios":"A peer on a newer protocol that defined additional message types; a corrupted type byte; hand-crafted frames with arbitrary type values.","commonSituations":"Forward-compatibility breaks when one side is upgraded first; fuzzed input into the reader; experimental forks adding message types.","solutions":["Align both ends to the same typescript-go version","Treat unknown types as fatal for the connection - the frame layout cannot be assumed; close it","If you control the peer, restrict emitted types to the shared known set","Log the value: 7+ strongly suggests a newer protocol than this reader"],"exampleFix":"// before\nwriteTuple(MessageType(9), ...) // undefined type\n\n// after\nwriteTuple(MessageTypeRequest, ...) // value in 1..6","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"// Only for peers you control: restrict emitted types to the shared valid set.\nfunc validMessageType(t api.MessageType) bool { return t.IsValid() }","tryCatchPattern":"if err != nil && errors.Is(err, api.ErrInvalidRequest) {\n\tif strings.Contains(err.Error(), \"unknown message type\") {\n\t\t// peer speaks a newer protocol; reconnect with matched versions\n\t\treturn reconnectWithPinnedVersion()\n\t}\n}","preventionTips":["Lock both ends to the same typescript-go version","Treat unknown types as connection-fatal","Log the numeric type to detect forward-compatibility gaps"],"tags":["go","msgpack","message-type","version-skew","protocol"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}