{"record":{"id":"64d92ba1a380b63e","repo":"Comfy-Org/ComfyUI","slug":"bboxes-string-input-is-not-valid-json-exc","errorCode":null,"errorMessage":"bboxes string input is not valid JSON: {exc}","messagePattern":"bboxes string input is not valid JSON: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_bounding_boxes.py","lineNumber":244,"sourceCode":"                \"text\": element.get(\"text\", \"\") if etype == \"text\" else \"\",\n                \"desc\": element.get(\"desc\", \"\"),\n                \"palette\": element.get(\"color_palette\", []) or [],\n            },\n        })\n    return boxes\n\n\ndef boxes_from_input(data, width: int, height: int) -> list:\n    if data is None:\n        return []\n    if isinstance(data, str):\n        text = data.strip()\n        if not text:\n            return []\n        try:\n            data = json.loads(text)\n        except (ValueError, TypeError) as exc:\n            raise ValueError(f\"bboxes string input is not valid JSON: {exc}\") from exc\n    if isinstance(data, dict):\n        if _looks_like_element(data):\n            return elements_to_boxes([data], width, height)\n        if _looks_like_bbox(data):\n            return normalize_incoming_boxes(data)\n        raise ValueError(\n            \"bboxes dict must be a bounding box (x, y, width, height) or an element (with a 'bbox')\"\n        )\n    if not isinstance(data, list):\n        raise ValueError(\n            \"bboxes input must be bounding boxes, elements, or a JSON string, \"\n            f\"got {type(data).__name__}\"\n        )\n    if not data:\n        return []\n    first = data[0]\n    if isinstance(first, list):\n        return normalize_incoming_boxes(data)","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_bounding_boxes.py#L226-L262","documentation":"boxes_from_input accepts a JSON string, dict, or list. When a non-empty string arrives it must parse as JSON via json.loads; a parse failure (ValueError/TypeError from the JSON decoder) is re-raised with this message including the underlying parser error.","triggerScenarios":"Passing 'x:10,y:20,w:5,h:5' (not JSON), a truncated JSON string, trailing commas, single-quoted keys, or smart quotes copied from a chat/UI; an f-string that interpolated Python reprs into JSON.","commonSituations":"Paste-from-LLM bbox strings; prompt-template interpolation producing malformed JSON; widgets that send comma-separated coordinates instead of JSON.","solutions":["Validate the string parses with json.loads before wiring it in; fix syntax (double quotes, full brackets)","Generate the JSON programmatically (json.dumps) instead of string concatenation/f-strings","If the source emits CSV-style boxes, convert to JSON or pass a list/dict directly (the node accepts native lists/dicts, bypassing parsing)"],"exampleFix":"// before\nbboxes = \"x:10,y:20,width:100,height:50\"\n\n// after\nimport json\nbboxes = json.dumps([{\"x\": 10, \"y\": 20, \"width\": 100, \"height\": 50}])","handlingStrategy":"validation","validationCode":"import json\n\ndef parses_as_boxes_json(s: str) -> bool:\n    try:\n        json.loads(s)\n        return True\n    except (ValueError, TypeError):\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    boxes = boxes_from_input(text, w, h)\nexcept ValueError as e:\n    if 'not valid JSON' in str(e):\n        text = json.dumps(parse_custom_format(text))  # or fix and retry\n        boxes = boxes_from_input(text, w, h)\n    else:\n        raise","preventionTips":["Build JSON with json.dumps, never f-strings or concatenation","Parse-then-validate strings from LLMs/pastes before wiring them in","Pass native lists/dicts where possible to skip string parsing entirely"],"tags":["json","parsing","bounding-box"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}