{"record":{"id":"6136df58e9dcd507","repo":"earendil-works/pi","slug":"unable-to-encode-kind-protocol-message-bound","errorCode":null,"errorMessage":"Unable to encode ${kind} protocol message: ${boundedErrorMessage(error)}","messagePattern":"Unable to encode (.+?) protocol message: (.+?)","errorType":"exception","errorClass":"ProtocolValidationError","httpStatus":null,"severity":"error","filePath":"packages/protocol/src/codec.ts","lineNumber":74,"sourceCode":"\tif (!(error instanceof Error)) return \"Unknown codec error\";\n\treturn error.message.length <= 500 ? error.message : `${error.message.slice(0, 497)}...`;\n}\n\nfunction encodeProtocolMessage<T>(\n\tvalue: T,\n\tparse: (candidate: unknown) => T,\n\tkind: string,\n\toptions?: FrameDecoderOptions,\n): Uint8Array {\n\tconst validated = parse(value);\n\ttry {\n\t\tconst maxFrameLength = options?.maxFrameLength ?? DEFAULT_MAX_FRAME_LENGTH;\n\t\tconst frame = encodeFrame(encodeCbor(validated, { maxByteLength: maxFrameLength }));\n\t\tassertCompleteFrame(frame, { maxFrameLength });\n\t\treturn frame;\n\t} catch (error) {\n\t\tif (error instanceof ProtocolValidationError) throw error;\n\t\tthrow new ProtocolValidationError(`Unable to encode ${kind} protocol message: ${boundedErrorMessage(error)}`);\n\t}\n}\n\n/** Validates and encodes one complete length-prefixed client message. */\nexport function encodeClientMessage(message: ClientMessage, options?: FrameDecoderOptions): Uint8Array {\n\treturn encodeProtocolMessage(message, parseClientMessage, \"client\", options);\n}\n\n/** Validates and encodes one complete length-prefixed server message. */\nexport function encodeServerMessage(message: ServerMessage, options?: FrameDecoderOptions): Uint8Array {\n\treturn encodeProtocolMessage(message, parseServerMessage, \"server\", options);\n}\n\nclass ValidatedMessageDecoder<T> {\n\tprivate failed = false;\n\tprivate readonly frames: FrameDecoder;\n\tprivate readonly kind: string;\n\tprivate readonly maxFrameLength: number;","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/protocol/src/codec.ts#L56-L92","documentation":"Error \"Unable to encode ${kind} protocol message: ${boundedErrorMessage(error)}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/protocol/src/codec.ts:74 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error: the message failed to encode. Check for unsupported values in the payload."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}