can1357/oh-my-pi · error · Error

Invalid number: ${rawValue}

Error message

Invalid number: ${rawValue}

What it means

For number-typed settings, `omp config set` coerces the trimmed value with Number() and requires a finite result. If the value parses to NaN or Infinity (or is empty/non-numeric), this error is thrown and the setting is left unchanged.

Source

Thrown at packages/coding-agent/src/cli/config-cli.ts:193

// Schema-Driven Value Parsing
// =============================================================================

function parseAndSetValue(path: SettingPath, rawValue: string): void {
	const schemaType = getType(path);
	let parsedValue: unknown;

	const trimmed = rawValue.trim();
	switch (schemaType) {
		case "boolean": {
			const lower = trimmed.toLowerCase();
			if (["true", "1", "yes", "on"].includes(lower)) parsedValue = true;
			else if (["false", "0", "no", "off"].includes(lower)) parsedValue = false;
			else throw new Error(`Invalid boolean value: ${rawValue}. Use true/false, yes/no, on/off, or 1/0`);
			break;
		}
		case "number":
			parsedValue = Number(trimmed);
			if (!Number.isFinite(parsedValue)) throw new Error(`Invalid number: ${rawValue}`);
			break;
		case "enum": {
			const valid = getEnumValues(path);
			if (valid && !valid.includes(trimmed)) {
				throw new Error(`Invalid value: ${rawValue}. Valid values: ${valid.join(", ")}`);
			}
			parsedValue = trimmed;
			break;
		}
		case "array": {
			let parsed: unknown;
			try {
				parsed = JSON.parse(trimmed);
			} catch {
				throw new Error(`Invalid array JSON: ${rawValue}`);
			}
			if (!Array.isArray(parsed)) {
				throw new Error(`Invalid array JSON: ${rawValue}`);

View on GitHub (pinned to 9690622007)

Solutions

  1. Pass a plain finite number without units: `omp config set <key> 500`.
  2. Convert units yourself before setting (ms → number, % → fraction).
  3. Check the variable you're interpolating isn't empty or malformed: `echo "$MY_VALUE"` first.
  4. Run `omp config get <key>` to confirm the setting's type is number.

Example fix

// before
$ omp config set request-timeout 500ms
// after
$ omp config set request-timeout 500
Defensive patterns

Strategy: validation

Validate before calling

function setNumber(key: string, raw: string) {
  const n = Number(raw.trim());
  if (!Number.isFinite(n)) throw new Error(`${raw} is not a finite number`);
  return Bun.$`omp config set ${key} ${String(n)}`;
}

Prevention

When it happens

Trigger: `omp config set <number-key> <value>` where <value> is non-numeric text, empty, or something like `10ms`, `50%`, `1e999` (Infinity).

Common situations: Including units in the value (`500ms` instead of `500`); typos like `0,5` (comma decimal); locale-formatted numbers with thousands separators; empty string from an unquoted shell variable.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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