can1357/oh-my-pi · error

Destination option ${key} must be a finite number

Error message

Destination option ${key} must be a finite number

What it means

optionNumber reads a numeric destination option and throws when the value is not a number or is NaN/Infinity. Numeric options (port, expiryDays, ttlSeconds) must be real finite numbers because they are used in arithmetic and URL construction downstream. This guard prevents string-typed numbers from leaking into numeric code paths.

Source

Thrown at packages/coding-agent/src/blob-broker/uploader-runtime.ts:65

	const value = config.options[key];
	if (value === undefined) throw new Error(`Missing required destination option: ${key}`);
	return value;
}

/** Read a string option, returning a fallback when it is absent. */
export function optionString(config: DestinationRuntimeConfig, key: string, fallback?: string): string | undefined {
	const value = config.options[key];
	if (value === undefined) return fallback;
	if (typeof value !== "string") throw new Error(`Destination option ${key} must be a string`);
	return value;
}

/** Read a number option, returning a fallback when it is absent. */
export function optionNumber(config: DestinationRuntimeConfig, key: string, fallback?: number): number | undefined {
	const value = config.options[key];
	if (value === undefined) return fallback;
	if (typeof value !== "number" || !Number.isFinite(value)) {
		throw new Error(`Destination option ${key} must be a finite number`);
	}
	return value;
}

/** Read a boolean option, returning a fallback when it is absent. */
export function optionBoolean(config: DestinationRuntimeConfig, key: string, fallback?: boolean): boolean | undefined {
	const value = config.options[key];
	if (value === undefined) return fallback;
	if (typeof value !== "boolean") throw new Error(`Destination option ${key} must be a boolean`);
	return value;
}

/** Read a credential without exposing its value in an error. */
export function credentialString(config: DestinationRuntimeConfig, key: string): string | undefined {
	const value = config.credentials[key];
	return value === "" ? undefined : value;
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Remove quotes so the value is a JSON/YAML number: `"ttlSeconds": 3600`.
  2. Convert duration strings to the numeric field the option expects, or use the string-typed `ttl` option if the destination supports one.
  3. Check for Infinity/NaN sources if the value is generated programmatically before passing it into options.

Example fix

// before
{ "options": { "port": "8080" } }
// after
{ "options": { "port": 8080 } }
Defensive patterns

Strategy: validation

Validate before calling

function assertNumberOption(options: Record<string, unknown>, key: string): void {
  const v = options[key];
  if (v !== undefined && (typeof v !== "number" || !Number.isFinite(v))) throw new Error(`option ${key} must be a finite number`);
}
assertNumberOption(config.options, "ttlSeconds");

Type guard

const isFiniteNumber = (v: unknown): v is number => typeof v === "number" && Number.isFinite(v);

Try / catch

try {
  const port = optionNumber(config, "port");
} catch (err) {
  throw new Error(`destination config: ${String(err)}`, { cause: err });
}

Prevention

When it happens

Trigger: Calling optionNumber(config, key) — via port, expiryDays, or ttlSeconds — when config.options[key] is a string like "3600", a boolean, or a non-finite number such as Infinity produced by an expression in config.

Common situations: JSON config with `"ttlSeconds": "3600"` (quoted), computed values yielding Infinity, YAML unquoted floats misparsed, or users copying durations like "1h" into a numeric field.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/313c04b9ce4b8704. Report an issue: GitHub.