{"record":{"id":"776521a443a2e3c8","repo":"can1357/oh-my-pi","slug":"expected-or-in-object","errorCode":null,"errorMessage":"Expected ',' or '}' in object","messagePattern":"Expected ',' or '\\}' in object","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/json-parse.ts","lineNumber":299,"sourceCode":"\t\t\tif (this.#i >= this.#n) {\n\t\t\t\tif (this.#partial) return out;\n\t\t\t\tthrow new SyntaxError(\"Expected value after ':'\");\n\t\t\t}\n\t\t\tconst value = this.#value(true);\n\t\t\tif (value === INCOMPLETE) return out;\n\t\t\tout[key] = value;\n\t\t\tthis.#ws();\n\t\t\tconst d = this.#i < this.#n ? this.#s[this.#i] : \"\";\n\t\t\tif (d === \",\") {\n\t\t\t\tthis.#i++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (d === \"}\") {\n\t\t\t\tthis.#i++;\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\tif (this.#partial) return out;\n\t\t\tthrow new SyntaxError(\"Expected ',' or '}' in object\");\n\t\t}\n\t}\n\n\t#array(): unknown[] {\n\t\tthis.#i++; // consume [\n\t\tconst out: unknown[] = [];\n\t\tfor (;;) {\n\t\t\tthis.#ws();\n\t\t\tif (this.#i >= this.#n) {\n\t\t\t\tif (this.#partial) return out;\n\t\t\t\tthrow new SyntaxError(\"Unterminated array\");\n\t\t\t}\n\t\t\tconst c = this.#s[this.#i];\n\t\t\tif (c === \"]\") {\n\t\t\t\tthis.#i++;\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\tif (c === \",\") {","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/json-parse.ts#L281-L317","documentation":"Thrown by RelaxedJson.#object in strict mode after a value when the next character is neither ',' nor '}' — the object's members are not properly delimited. The relaxed parser already tolerates leading/doubled/trailing commas, so this only fires for genuinely bad delimiters; partial mode returns the object so far instead of throwing.","triggerScenarios":"parseJsonWithRepair with '{\"a\": 1 \"b\": 2}' (missing comma), '{\"a\": 1 )}', or any char other than ',' / '}' between members in strict mode.","commonSituations":"An LLM emitting space-separated key/value pairs without commas; template string interpolation that dropped a comma; concatenation artifacts between two adjacent fields.","solutions":["Insert the missing ',' or '}' in the source JSON at the failing position","Use parseStreamingJson if the buffer may be a partial prefix (it returns the object parsed so far)","Regenerate the JSON from the producer; this malformation pattern from an LLM often repeats, so validate output against a schema before executing the tool call"],"exampleFix":"// before\nconst v = parseJsonWithRepair(`{\"a\": 1 \"b\": 2}`); // SyntaxError\n// after\nconst v = parseJsonWithRepair(`{\"a\": 1, \"b\": 2}`); // {a: 1, b: 2}","handlingStrategy":"validation","validationCode":"import { classifyJsonPrefix } from \"@oh-my-pi/pi-utils/json-parse\";\n// 'invalid' with a missing comma cannot be repaired — detect before parsing\nconst state = classifyJsonPrefix(text);","typeGuard":null,"tryCatchPattern":"try {\n  const value = parseJsonWithRepair<T>(text);\n} catch (err) {\n  if (err instanceof SyntaxError && err.message === \"Expected ',' or '}' in object\") {\n    // reject the tool call / regenerate the payload\n  } else throw err;\n}","preventionTips":["Always serialize with JSON.stringify instead of concatenating fragments","Insert delimiters explicitly when building JSON by hand; review template literals","Schema-validate LLM tool-call arguments and skip calls that fail structural validation"],"tags":["json","parse","object","delimiter","syntaxerror"],"backgroundTag":"json-missing-comma","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}