{"record":{"id":"a12e900a0b57123f","repo":"can1357/oh-my-pi","slug":"invalid-record-json-rawvalue","errorCode":null,"errorMessage":"Invalid record JSON: ${rawValue}","messagePattern":"Invalid record JSON: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/config-cli.ts","lineNumber":221,"sourceCode":"\t\tcase \"array\": {\n\t\t\tlet parsed: unknown;\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(trimmed);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Invalid array JSON: ${rawValue}`);\n\t\t\t}\n\t\t\tif (!Array.isArray(parsed)) {\n\t\t\t\tthrow new Error(`Invalid array JSON: ${rawValue}`);\n\t\t\t}\n\t\t\tparsedValue = parsed;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"record\": {\n\t\t\tlet parsed: unknown;\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(trimmed);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Invalid record JSON: ${rawValue}`);\n\t\t\t}\n\t\t\tif (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n\t\t\t\tthrow new Error(`Invalid record JSON: ${rawValue}`);\n\t\t\t}\n\t\t\tif (path === \"providers.maxInFlightRequests\") {\n\t\t\t\tparsed = validateProviderMaxInFlightRequests(parsed);\n\t\t\t}\n\t\t\tparsedValue = parsed;\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tparsedValue = trimmed;\n\t}\n\n\tsettings.set(path, parsedValue as SettingValue<typeof path>);\n}\n\n// =============================================================================","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/config-cli.ts#L203-L239","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass the value as a single, properly shell-quoted JSON object: omp config set <path> '{\"key\": 2}'","Verify the value parses as an object: echo '<value>' | jq -e 'type == \"object\"'","Use single quotes on POSIX shells (or escaped double quotes on Windows cmd) so inner quotes survive","If you intended a list or scalar, check the config path's expected type; record paths only accept objects"],"exampleFix":"// before\nomp config set providers.maxInFlightRequests {\"x-groq\": 2}   // shell strips quotes -> parse error\n// after\nomp config set providers.maxInFlightRequests '{\"x-groq\": 2}'","handlingStrategy":"validation","validationCode":"function isValidRecordJson(raw) {\n  try {\n    const v = JSON.parse(raw);\n    return v !== null && typeof v === 'object' && !Array.isArray(v);\n  } catch { return false; }\n}\n// if (!isValidRecordJson(value)) throw new Error('value must be a JSON object');","typeGuard":"function isRecord(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  const parsed = JSON.parse(rawValue);\n  if (!isRecord(parsed)) throw new Error(`Invalid record JSON: ${rawValue}`);\n} catch (e) {\n  console.error(`Config set failed: ${(e as Error).message}. Value must be a JSON object.`);\n  process.exitCode = 1;\n}","preventionTips":["Single-quote JSON values on the shell so inner quotes survive","Pre-validate with jq: jq -e 'type == \"object\"' before passing the value","Remember record paths need objects, never arrays or scalars"],"tags":["cli","config","json-parsing","validation"],"backgroundTag":"invalid-json-input","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}