earendil-works/pi · error · ProtocolValidationError
Unable to encode ${kind} protocol message: ${boundedErrorMes
Error message
Unable to encode ${kind} protocol message: ${boundedErrorMessage(error)} What it means
Error "Unable to encode ${kind} protocol message: ${boundedErrorMessage(error)}" thrown in earendil-works/pi.
Source
Thrown at packages/protocol/src/codec.ts:74
if (!(error instanceof Error)) return "Unknown codec error";
return error.message.length <= 500 ? error.message : `${error.message.slice(0, 497)}...`;
}
function encodeProtocolMessage<T>(
value: T,
parse: (candidate: unknown) => T,
kind: string,
options?: FrameDecoderOptions,
): Uint8Array {
const validated = parse(value);
try {
const maxFrameLength = options?.maxFrameLength ?? DEFAULT_MAX_FRAME_LENGTH;
const frame = encodeFrame(encodeCbor(validated, { maxByteLength: maxFrameLength }));
assertCompleteFrame(frame, { maxFrameLength });
return frame;
} catch (error) {
if (error instanceof ProtocolValidationError) throw error;
throw new ProtocolValidationError(`Unable to encode ${kind} protocol message: ${boundedErrorMessage(error)}`);
}
}
/** Validates and encodes one complete length-prefixed client message. */
export function encodeClientMessage(message: ClientMessage, options?: FrameDecoderOptions): Uint8Array {
return encodeProtocolMessage(message, parseClientMessage, "client", options);
}
/** Validates and encodes one complete length-prefixed server message. */
export function encodeServerMessage(message: ServerMessage, options?: FrameDecoderOptions): Uint8Array {
return encodeProtocolMessage(message, parseServerMessage, "server", options);
}
class ValidatedMessageDecoder<T> {
private failed = false;
private readonly frames: FrameDecoder;
private readonly kind: string;
private readonly maxFrameLength: number;View on GitHub (pinned to 4af9d21d3b)
Solutions
- Inspect the wrapped error: the message failed to encode. Check for unsupported values in the payload.
When it happens
Trigger: Thrown at packages/protocol/src/codec.ts:74 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/6136df58e9dcd507.
Report an issue: GitHub.