can1357/oh-my-pi · warning
Invalid record JSON for ${path}
Error message
Invalid record JSON for ${path} What it means
For settings paths whose schema type is 'record', the value string must parse as JSON into a plain object (not null, not an array). If JSON.parse fails — including on empty input treated as '{}'... actually empty input defaults to '{}' and only genuinely malformed JSON throws this error naming the settings path.
Source
Thrown at packages/coding-agent/src/modes/components/settings-selector.ts:1288
return String(value);
}
/**
* Set a setting value, handling type conversion.
*/
#setSettingValue(path: SettingPath, value: string): void {
const currentValue = settings.get(path);
const schemaType = getType(path);
if (path === "compaction.thresholdPercent" && value === "default") {
settings.set(path, -1 as never);
} else if (path === "compaction.thresholdTokens" && value === "default") {
settings.set(path, -1 as never);
} else if (schemaType === "record") {
let parsed: unknown;
try {
parsed = JSON.parse(value || "{}");
} catch {
throw new Error(`Invalid record JSON for ${path}`);
}
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
throw new Error(`Invalid record JSON for ${path}`);
}
if (path === "providers.maxInFlightRequests") {
parsed = validateProviderMaxInFlightRequests(parsed);
}
settings.set(path, parsed as never);
} else if (typeof currentValue === "number") {
settings.set(path, Number(value) as never);
} else if (typeof currentValue === "boolean") {
settings.set(path, (value === "true") as never);
} else {
settings.set(path, value as never);
}
}
/**View on GitHub (pinned to 9690622007)
Solutions
- Fix the JSON syntax: quote keys and string values, no trailing commas, object not array
- Use double quotes: {"provider-name": 4} for providers.maxInFlightRequests
- Enter {} (or leave the field's default) for an empty record
- Validate the JSON in a linter/editor before pasting into the settings editor
Example fix
// before
{anthropic: 4,} // invalid JSON -> throws
// after
{"anthropic": 4} // valid record Defensive patterns
Strategy: validation
Validate before calling
let parsed: unknown;
try { parsed = JSON.parse(value || "{}"); } catch { throw new Error("Invalid record JSON"); }
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("Record must be a JSON object"); Type guard
function isPlainObject(v: unknown): v is Record<string, unknown> {
return typeof v === "object" && v !== null && !Array.isArray(v);
} Try / catch
try {
selector.setRecordValue(path, value);
} catch (err) {
if (err instanceof Error && err.message.startsWith("Invalid record JSON")) {
// re-prompt with corrected JSON object syntax
} else throw err;
} Prevention
- Always submit double-quoted JSON objects for record settings
- Validate JSON in an editor/linter before pasting
- Use {} for an empty record
- Remember empty input defaults to '{}' — only malformed JSON throws
When it happens
Trigger: Editing a record-typed setting (e.g. providers.maxInFlightRequests or any record<T,U> schema) and submitting a value that JSON.parse cannot parse — e.g. '{anthropic: 4}' (unquoted keys), '[]' hits the second throw variant, 'not json', trailing commas.
Common situations: Hand-writing JSON with unquoted keys or single quotes; pasting a JS object literal instead of JSON; entering an array where an object record is required; forgetting to quote provider names.
Related errors
- OMP_AUTH_BROKER_ACCOUNT_POOL_FILE contains an empty provider
- OMP_AUTH_BROKER_ACCOUNT_POOL_FILE contains a provider id wit
- Validation failed for tool "${toolCall.name}": Tool call arg
- ${destination} returned an invalid response
- Invalid array JSON: ${rawValue}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/26222e74f6ba406b.
Report an issue: GitHub.