can1357/oh-my-pi · error · Error

Invalid record JSON: ${rawValue}

Error message

Invalid record JSON: ${rawValue}

What it means

Thrown by parseAndSetValue in the `omp config set` CLI when the value for a `record`-typed config path fails to parse or is not a JSON object. The command only accepts flat JSON objects (e.g. `{"a":1}`); raw JSON, arrays, null, primitives, and syntactically invalid JSON are all rejected. The raw user input is echoed back in the message.

Source

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

		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}`);
			}
			parsedValue = parsed;
			break;
		}
		case "record": {
			let parsed: unknown;
			try {
				parsed = JSON.parse(trimmed);
			} catch {
				throw new Error(`Invalid record JSON: ${rawValue}`);
			}
			if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
				throw new Error(`Invalid record JSON: ${rawValue}`);
			}
			if (path === "providers.maxInFlightRequests") {
				parsed = validateProviderMaxInFlightRequests(parsed);
			}
			parsedValue = parsed;
			break;
		}
		default:
			parsedValue = trimmed;
	}

	settings.set(path, parsedValue as SettingValue<typeof path>);
}

// =============================================================================

View on GitHub (pinned to 9690622007)

Solutions

  1. Pass the value as a single, properly shell-quoted JSON object: omp config set <path> '{"key": 2}'
  2. Verify the value parses as an object: echo '<value>' | jq -e 'type == "object"'
  3. Use single quotes on POSIX shells (or escaped double quotes on Windows cmd) so inner quotes survive
  4. If you intended a list or scalar, check the config path's expected type; record paths only accept objects

Example fix

// before
omp config set providers.maxInFlightRequests {"x-groq": 2}   // shell strips quotes -> parse error
// after
omp config set providers.maxInFlightRequests '{"x-groq": 2}'
Defensive patterns

Strategy: validation

Validate before calling

function isValidRecordJson(raw) {
  try {
    const v = JSON.parse(raw);
    return v !== null && typeof v === 'object' && !Array.isArray(v);
  } catch { return false; }
}
// if (!isValidRecordJson(value)) throw new Error('value must be a JSON object');

Type guard

function isRecord(v: unknown): v is Record<string, unknown> {
  return typeof v === 'object' && v !== null && !Array.isArray(v);
}

Try / catch

try {
  const parsed = JSON.parse(rawValue);
  if (!isRecord(parsed)) throw new Error(`Invalid record JSON: ${rawValue}`);
} catch (e) {
  console.error(`Config set failed: ${(e as Error).message}. Value must be a JSON object.`);
  process.exitCode = 1;
}

Prevention

When it happens

Trigger: Running `omp config set <record-path> <value>` where value is: (1) not valid JSON at all (unquoted braces, missing quotes); (2) a JSON array like `[1,2]`; (3) `null`, a number, string, or boolean; (4) valid JSON that the shell mangled (quotes stripped) before reaching the parser.

Common situations: Users setting providers.maxInFlightRequests or similar record paths pass shell-unquoted JSON like `{"x-groq":2}` — the shell eats the quotes and JSON.parse sees `{x-groq:2}`, failing. Others paste arrays or forget the value must be an object, not a scalar.

Related errors


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