{"record":{"id":"04408b9b40af65cc","repo":"microsoft/typescript-go","slug":"w-expected-positive-fixint-or-uint8-marker-rece","errorCode":null,"errorMessage":"%w: expected positive fixint or uint8 marker, received: 0x%02x","messagePattern":"%w: expected positive fixint or uint8 marker, received: 0x%02x","errorType":"validation","errorClass":"ErrInvalidRequest","httpStatus":null,"severity":"error","filePath":"internal/api/protocol_msgpack.go","lineNumber":122,"sourceCode":"\t}\n\n\t// Read message type - can be positive fixint (0x00-0x7F) or uint8 (0xCC + value)\n\tt, err = p.r.ReadByte()\n\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}","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/api/protocol_msgpack.go#L104-L140","documentation":"The second byte of a tuple must encode the message type as a msgpack positive fixint (0x00-0x7f, the byte is the value) or a uint8 marker (0xCC followed by one value byte). Any other marker - negative fixint, string, array - means the stream is misaligned by one byte or the peer is not writing this format. Wraps ErrInvalidRequest.","triggerScenarios":"Same desync causes as the 0x93 failure but shifted one byte; a non-reference encoder emitting msgpack strings or arrays for the type field.","commonSituations":"Hand-rolled msgpack encoders in other-language clients using str markers for small integers; byte insertion/deletion by a faulty transport.","solutions":["Use the reference encoding: 0x93, raw type byte, then bin8/16/32 fields","There is no in-stream resync - close and reopen the connection after a framing error","Check that nothing else reads from the same underlying conn","Add a length-prefix or checksum layer if the transport is lossy"],"exampleFix":"# before (peer writes type as msgpack str)\n93 a1 02 ... \n\n# after (reference encoding: fixint type byte)\n93 02 c4 0b 6765744469676e6f7374696373 ...","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && errors.Is(err, api.ErrInvalidRequest) {\n\tlog.Printf(\"bad type marker byte 0x%02x: stream misaligned; resetting connection\", t)\n\treturn resetConnection()\n}","preventionTips":["In non-Go clients, write the type as a raw fixint byte exactly like writeTuple","Never share the underlying reader with other code","Close and reopen on any framing error - there is no resync"],"tags":["go","msgpack","framing","encoding","desync"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}