{"record":{"id":"fedd70484b548faf","repo":"JuliusBrussee/caveman","slug":"comma","errorCode":null,"errorMessage":"comma","messagePattern":"comma","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/middleware/python/caveman_middleware/_google_wire.py","lineNumber":49,"sourceCode":"                index += 1\n                return result\n            while True:\n                white()\n                key, index = decoder.raw_decode(text, index)\n                if type(key) is not str or key in result:\n                    raise ValueError(\"duplicate\")\n                white()\n                if text[index] != \":\":\n                    raise ValueError(\"colon\")\n                index += 1\n                result[key] = walk((*path, key), depth + 1)\n                white()\n                end = text[index]\n                index += 1\n                if end == \"}\":\n                    return result\n                if end != \",\":\n                    raise ValueError(\"comma\")\n        if text[index] == \"[\":\n            index += 1\n            result = []\n            white()\n            if text[index] == \"]\":\n                index += 1\n                return result\n            while True:\n                result.append(walk((*path, len(result)), depth + 1))\n                white()\n                end = text[index]\n                index += 1\n                if end == \"]\":\n                    return result\n                if end != \",\":\n                    raise ValueError(\"comma\")\n        value, index = decoder.raw_decode(text, index)\n        return value","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/middleware/python/caveman_middleware/_google_wire.py#L31-L67","documentation":"ValueError from the hand-rolled JSON walker in _google_wire.py: after a key/value pair inside an object, the next character was neither ',' (more pairs) nor '}' (end of object). The message names the expected separator token ('comma').","triggerScenarios":"Parsing JSON objects with missing commas between members ({\"a\":1 \"b\":2}), trailing content, or truncation right after a value, via parse().","commonSituations":"Truncated network payloads; string-templated JSON missing separators; newline-delimited JSON accidentally fed as a single document; manual edits removing commas.","solutions":["Repair the JSON by inserting the missing ',' between members","Validate with json.loads before calling parse to pinpoint the syntax error","Check the transport/producer for truncation and re-fetch the payload","Catch ValueError and fall back to line-by-line JSON parsing for NDJSON input"],"exampleFix":"# before\nvalue = parse('{\"a\": 1 \"b\": 2}')  # ValueError: comma\n# after\nvalue = parse('{\"a\": 1, \"b\": 2}')","handlingStrategy":"try-catch","validationCode":"import json\ndef is_well_formed_json(text):\n    try:\n        json.loads(text)\n        return True\n    except json.JSONDecodeError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    value = parse(text)\nexcept ValueError as e:\n    if str(e) == \"comma\":\n        raise ValueError(\"Malformed JSON object: expected ',' or '}' between members\") from e","preventionTips":["Check for truncated responses (Content-Length mismatches) before parsing","Parse NDJSON line-by-line instead of feeding a concatenated stream","Use json.dumps on the producer side to guarantee separators","Pre-validate with stdlib json.loads to catch syntax errors with better messages"],"tags":["python","json","malformed","parsing"],"backgroundTag":"json-parse-error","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}