earendil-works/pi · error · CborError

Decoded CBOR number must be finite

Error message

Decoded CBOR number must be finite

What it means

Error "Decoded CBOR number must be finite" thrown in earendil-works/pi.

Source

Thrown at packages/protocol/src/cbor/decoder.ts:99

			case 7:
				return this.readSimple(additionalInformation);
			default:
				throw new CborError("Malformed CBOR major type");
		}
	}

	private readSimple(additionalInformation: number): unknown {
		switch (additionalInformation) {
			case 20:
				return false;
			case 21:
				return true;
			case 22:
				return null;
			case 27: {
				const bytes = this.readBytes(8);
				const value = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getFloat64(0, false);
				if (!Number.isFinite(value)) throw new CborError("Decoded CBOR number must be finite");
				if (Number.isInteger(value) && !Number.isSafeInteger(value)) {
					throw new CborError("Decoded CBOR integer is outside the safe range");
				}
				return value;
			}
			case 31:
				throw new CborError("CBOR break marker is not supported");
			default:
				throw new CborError("Unsupported CBOR simple value or floating-point width");
		}
	}

	private readLength(additionalInformation: number, kind: string, limit: number): number {
		if (additionalInformation === 31) throw new CborError(`Indefinite-length CBOR ${kind}s are not supported`);
		const length = this.readArgument(additionalInformation);
		if (length > limit) throw new CborError(`CBOR ${kind} length exceeds configured limit of ${limit}`);
		return length;
	}

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Ensure encoded numbers are finite; NaN and Infinity are rejected. Filter them out before encoding.

When it happens

Trigger: Thrown at packages/protocol/src/cbor/decoder.ts:99 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/996c57f6f59c059c. Report an issue: GitHub.