earendil-works/pi · error · CborError
Decoded CBOR integer or length is outside the safe range
Error message
Decoded CBOR integer or length is outside the safe range
What it means
A 64-bit CBOR argument (additional information 27, read as high/low 32-bit halves) exceeds 2^53-1, the largest safe JavaScript integer. The decoder refuses to lose precision on large integers or lengths, so values above the safe range are rejected.
Solutions
- The integer or length exceeds Number.MAX_SAFE_INTEGER. Use smaller values or a BigInt-aware encoding.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/protocol/src/cbor/decoder.ts:135 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/9b2bd74dc732e8f8.
Report an issue: GitHub.
Appendix: source
Thrown at packages/protocol/src/cbor/decoder.ts:135
}
private readArgument(additionalInformation: number): number {
if (additionalInformation < 24) return additionalInformation;
switch (additionalInformation) {
case 24:
return this.readByte();
case 25: {
const bytes = this.readBytes(2);
return bytes[0]! * 0x100 + bytes[1]!;
}
case 26: {
const bytes = this.readBytes(4);
return bytes[0]! * 0x1_000_000 + bytes[1]! * 0x1_0000 + bytes[2]! * 0x100 + bytes[3]!;
}
case 27: {
const high = this.readArgument(26);
const low = this.readArgument(26);
if (high > 0x1f_ffff) throw new CborError("Decoded CBOR integer or length is outside the safe range");
return high * UINT32_BASE + low;
}
case 31:
throw new CborError("Indefinite-length CBOR items are not supported");
default:
throw new CborError("Malformed CBOR additional information");
}
}
private readByte(): number {
if (this.offset >= this.bytes.byteLength) throw new CborError("Truncated CBOR payload");
const value = this.bytes[this.offset]!;
this.offset++;
return value;
}
private readBytes(length: number): Uint8Array {
if (length > this.bytes.byteLength - this.offset) throw new CborError("Truncated CBOR payload");View on GitHub (pinned to 4af9d21d3b)