{"record":{"id":"7a22ce87cf4c41c5","repo":"Comfy-Org/ComfyUI","slug":"bboxes-items-must-be-bounding-boxes-x-y-width","errorCode":null,"errorMessage":"bboxes items must be bounding boxes (x, y, width, height) or elements (with a 'bbox')","messagePattern":"bboxes items must be bounding boxes \\(x, y, width, height\\) or elements \\(with a 'bbox'\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_bounding_boxes.py","lineNumber":268,"sourceCode":"        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)\n    if isinstance(first, dict):\n        if _looks_like_element(first):\n            return elements_to_boxes(data, width, height)\n        if _looks_like_bbox(first):\n            return normalize_incoming_boxes(data)\n        raise ValueError(\n            \"bboxes items must be bounding boxes (x, y, width, height) or elements (with a 'bbox')\"\n        )\n    raise ValueError(\n        f\"bboxes list must contain bounding boxes or elements, got {type(first).__name__}\"\n    )\n\n\ndef _norm_bbox(region: dict) -> list[int]:\n    def grid(value: float) -> int:\n        return max(0, min(1000, round(value * 1000)))\n\n    x, y = region.get(\"x\", 0.0), region.get(\"y\", 0.0)\n    w, h = region.get(\"w\", 0.0), region.get(\"h\", 0.0)\n    ymin, xmin, ymax, xmax = grid(y), grid(x), grid(y + h), grid(x + w)\n    if ymin > ymax:\n        ymin, ymax = ymax, ymin\n    if xmin > xmax:\n        xmin, xmax = xmax, xmin","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_bounding_boxes.py#L250-L286","documentation":"For list input, boxes_from_input dispatches on the first item: a list means corner boxes, a dict means elements or x/y/width/height boxes. A dict first item that has neither a bbox key nor all of x/y/width/height triggers this error (the per-item analogue of 837).","triggerScenarios":"A list of dicts using alternate key conventions ({'x1','y1','x2','y2'}, {'top','left',...}, {'w','h'}); mixed lists where only some entries are malformed; empty dict entries {} from filtered upstream data.","commonSituations":"Batch-converting another tool's bbox list where one or more entries use a different schema; LLM output lists with inconsistent keys across items.","solutions":["Normalize every dict in the list to x/y/width/height or element+bbox schema, not just the first","Filter out empty/malformed entries before passing the list","Add a pre-validation pass that reports which indices fail the schema so fixes are targeted"],"exampleFix":"// before\n[{\"x1\": 0, \"y1\": 0, \"x2\": 50, \"y2\": 50}, {\"x\": 0, \"y\": 0, \"width\": 10, \"height\": 10}]\n\n// after\n[{\"x\": 0, \"y\": 0, \"width\": 50, \"height\": 50}, {\"x\": 0, \"y\": 0, \"width\": 10, \"height\": 10}]","handlingStrategy":"validation","validationCode":"def normalize_box_items(items):\n    out = []\n    for it in items:\n        if isinstance(it, dict):\n            if all(k in it for k in ('x', 'y', 'width', 'height')):\n                out.append(it)\n            elif isinstance(it.get('bbox'), (list, tuple)) and len(it['bbox']) == 4:\n                out.append(it)\n            # else: log and drop malformed entry\n    return out","typeGuard":"def is_valid_box_item(it) -> bool:\n    if not isinstance(it, dict):\n        return False\n    return all(k in it for k in ('x', 'y', 'width', 'height')) or (\n        isinstance(it.get('bbox'), (list, tuple)) and len(it['bbox']) == 4)","tryCatchPattern":"try:\n    boxes = boxes_from_input(data, w, h)\nexcept ValueError as e:\n    if 'must be bounding boxes' in str(e) or 'list must contain' in str(e):\n        data = [it for it in data if is_valid_box_item(it)]\n        boxes = boxes_from_input(data, w, h)\n    else:\n        raise","preventionTips":["Normalize every item's keys, not just the first","Filter empty/malformed dicts before batch conversion","Report failing indices during validation for targeted fixes"],"tags":["json","bounding-box","schema-mismatch","list-validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}