earendil-works/pi · error · TypeError

Eval input must contain only finite numbers.

Error message

Eval input must contain only finite numbers.

What it means

canonicalizeJson rejects non-finite numbers (NaN, Infinity) because JSON.stringify would render them as null, silently changing the input key hash used to identify eval runs.

Solutions

  1. Remove or replace NaN/Infinity values in the eval input
  2. Use null or a finite sentinel value instead of non-finite numbers
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/evals/src/vitest-evals/harness-table.ts:69 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/f7bab27ff9dd66a2. Report an issue: GitHub.

Appendix: source

Thrown at packages/evals/src/vitest-evals/harness-table.ts:69

	if (
		schemaVersion !== 1 ||
		typeof evalSet !== "string" ||
		typeof groupKey !== "string" ||
		typeof harness !== "string" ||
		typeof baseline !== "string" ||
		!Array.isArray(candidates) ||
		!candidates.every((name): name is string => typeof name === "string") ||
		typeof repetition !== "number"
	) {
		return undefined;
	}
	return { schemaVersion, evalSet, groupKey, harness, baseline, candidates, repetition };
}

function canonicalizeJson(value: unknown, ancestors: WeakSet<object>): JsonValue {
	if (value === null || typeof value === "string" || typeof value === "boolean") return value;
	if (typeof value === "number") {
		if (!Number.isFinite(value)) throw new TypeError("Eval input must contain only finite numbers.");
		return value;
	}
	if (typeof value !== "object") throw new TypeError("Eval input must be JSON-serializable.");
	if (ancestors.has(value)) throw new TypeError("Eval input must not contain circular references.");

	ancestors.add(value);
	try {
		if (Array.isArray(value)) {
			const result: JsonValue[] = [];
			for (let index = 0; index < value.length; index += 1) {
				if (!Object.hasOwn(value, index)) throw new TypeError("Eval input arrays must not be sparse.");
				result.push(canonicalizeJson(value[index], ancestors));
			}
			return result;
		}
		const prototype = Object.getPrototypeOf(value);
		if (prototype !== Object.prototype && prototype !== null) {
			throw new TypeError("Eval input must contain only plain objects and arrays.");

View on GitHub (pinned to 4af9d21d3b)