{"record":{"id":"e2fbc0dbe8e18c76","repo":"paperclipai/paperclip","slug":"invalid-json-err-instanceof-error-err-message","errorCode":null,"errorMessage":"Invalid JSON: ${err instanceof Error ? err.message : String(err)}","messagePattern":"Invalid JSON: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/client/project.ts","lineNumber":226,"sourceCode":"}\n\nfunction parseCsv(value: string | undefined): string[] | undefined {\n  if (value === undefined) return undefined;\n  return value.split(\",\").map((part) => part.trim()).filter(Boolean);\n}\n\nfunction parseNullableString(value: string | undefined): string | null | undefined {\n  if (value === undefined) return undefined;\n  return value.trim().toLowerCase() === \"null\" ? null : value;\n}\n\nfunction parseOptionalJson(value: string | undefined): unknown {\n  if (value === undefined) return undefined;\n  if (value.trim().toLowerCase() === \"null\") return null;\n  try {\n    return JSON.parse(value);\n  } catch (err) {\n    throw new Error(`Invalid JSON: ${err instanceof Error ? err.message : String(err)}`);\n  }\n}\n","sourceCodeStart":208,"sourceCodeEnd":229,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/cli/src/commands/client/project.ts#L208-L229","documentation":"parseOptionalJson wraps JSON.parse for --metadata-style options and rethrows parse failures with the parser's message; the input string is not valid JSON. This is a generic JSON-parse guard.","triggerScenarios":"Thrown at cli/src/commands/client/project.ts:226 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the JSON input; validate it with `jq` or a JSON linter before re-running."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}