{"record":{"id":"26222e74f6ba406b","repo":"can1357/oh-my-pi","slug":"invalid-record-json-for-path","errorCode":null,"errorMessage":"Invalid record JSON for ${path}","messagePattern":"Invalid record JSON for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/coding-agent/src/modes/components/settings-selector.ts","lineNumber":1288,"sourceCode":"\t\treturn String(value);\n\t}\n\n\t/**\n\t * Set a setting value, handling type conversion.\n\t */\n\t#setSettingValue(path: SettingPath, value: string): void {\n\t\tconst currentValue = settings.get(path);\n\t\tconst schemaType = getType(path);\n\t\tif (path === \"compaction.thresholdPercent\" && value === \"default\") {\n\t\t\tsettings.set(path, -1 as never);\n\t\t} else if (path === \"compaction.thresholdTokens\" && value === \"default\") {\n\t\t\tsettings.set(path, -1 as never);\n\t\t} else if (schemaType === \"record\") {\n\t\t\tlet parsed: unknown;\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(value || \"{}\");\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Invalid record JSON for ${path}`);\n\t\t\t}\n\t\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n\t\t\t\tthrow new Error(`Invalid record JSON for ${path}`);\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\tsettings.set(path, parsed as never);\n\t\t} else if (typeof currentValue === \"number\") {\n\t\t\tsettings.set(path, Number(value) as never);\n\t\t} else if (typeof currentValue === \"boolean\") {\n\t\t\tsettings.set(path, (value === \"true\") as never);\n\t\t} else {\n\t\t\tsettings.set(path, value as never);\n\t\t}\n\t}\n\n\t/**","sourceCodeStart":1270,"sourceCodeEnd":1306,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/components/settings-selector.ts#L1270-L1306","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n{anthropic: 4,}   // invalid JSON -> throws\n// after\n{\"anthropic\": 4}  // valid record","handlingStrategy":"validation","validationCode":"let parsed: unknown;\ntry { parsed = JSON.parse(value || \"{}\"); } catch { throw new Error(\"Invalid record JSON\"); }\nif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) throw new Error(\"Record must be a JSON object\");","typeGuard":"function isPlainObject(v: unknown): v is Record<string, unknown> {\n  return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  selector.setRecordValue(path, value);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Invalid record JSON\")) {\n    // re-prompt with corrected JSON object syntax\n  } else throw err;\n}","preventionTips":["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"],"tags":["json","validation","settings"],"backgroundTag":"invalid-json-input","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}