{"record":{"id":"4b679a07184de011","repo":"JuliusBrussee/caveman","slug":"colon","errorCode":null,"errorMessage":"colon","messagePattern":"colon","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/middleware/python/caveman_middleware/_google_wire.py","lineNumber":40,"sourceCode":"        if text[index] == '\"':\n            value, index = decoder.raw_decode(text, index)\n            strings[path] = (start, index, value)\n            return value\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                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))","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/middleware/python/caveman_middleware/_google_wire.py#L22-L58","documentation":"ValueError from the hand-rolled JSON walker in _google_wire.py: after decoding an object key, the next non-whitespace character was not ':'. The parser expected the key/value separator at this exact position; the message names the expected token ('colon').","triggerScenarios":"Parsing malformed JSON where a key is not followed by a colon, e.g. {\"a\" 1} or {\"a\" \"b\"}, via parse().","commonSituations":"Corrupted or truncated JSON in transit; hand-written JSON missing separators; concatenating JSON fragments; log-extracted JSON with characters stripped.","solutions":["Validate the JSON with json.loads first to get a standard parse error message pointing at the malformation","Fix the malformed text by inserting the missing ':' between key and value","Fix the producer/emitter generating broken JSON","Wrap parse() in try/except ValueError and surface a user-friendly invalid-JSON message"],"exampleFix":"# before\nvalue = parse('{\"model\" \"gpt\"}')  # ValueError: colon\n# after\nvalue = parse('{\"model\": \"gpt\"}')","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) == \"colon\":\n        raise ValueError(\"Malformed JSON object: expected ':' after key\") from e","preventionTips":["Pre-validate payloads with json.loads before the span-tracking parse","Repair corrupted payloads at the transport layer (retries/re-fetch)","Avoid hand-editing JSON in production paths","Log a snippet around the failure index to speed diagnosis"],"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"}