{"record":{"id":"040990b1ff95fd1f","repo":"Comfy-Org/ComfyUI","slug":"bboxes-list-must-contain-bounding-boxes-or-element","errorCode":null,"errorMessage":"bboxes list must contain bounding boxes or elements, got {type(first).__name__}","messagePattern":"bboxes list must contain bounding boxes or elements, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_bounding_boxes.py","lineNumber":271,"sourceCode":"    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\n    return [ymin, xmin, ymax, xmax]\n\n","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_bounding_boxes.py#L253-L289","documentation":"Raised by the bounding-box normalization helper in nodes_bounding_boxes.py when the first item of the `bboxes` input list is neither a list (nested box arrays), a dict that looks like an element (has a 'bbox' key) nor a dict that looks like a bbox. The node walks the list, inspects `type(data[0])`, and any scalar type (str, int, float, None, tuple at top level) falls through to this ValueError. It exists to reject malformed bbox payloads early instead of producing garbage crops/masks downstream.","triggerScenarios":"Passing a `bboxes` list whose first entry is a bare tuple like [(10,10,100,100)] (tuples are not lists, so `isinstance(first, list)` is False), a plain string, a number, or None. Also passing a dict that has neither a 'bbox' key nor the x/y/w/h shape recognized by `_looks_like_bbox` would hit the sibling dict error, but any non-list/non-dict first element hits this exact message.","commonSituations":"Hand-typing JSON where tuples are quoted as strings, wiring a primitive/STRING node or an int output into the bboxes input, or an upstream node changing its output type from list-of-lists to list-of-tuples or a comma-separated string.","solutions":["Convert tuple boxes to lists: pass [[x, y, w, h], ...] instead of [(x, y, w, h), ...].","If sending JSON as text, make sure it parses to a list of [x, y, width, height] arrays before it reaches this node.","Feed element dicts that include a 'bbox' key (e.g. results of layout-detection nodes) if you have elements rather than raw boxes.","Check the upstream node's output type in the workflow; rewire through a node that emits list-of-list boxes."],"exampleFix":"// before\nbboxes = [(10, 10, 100, 100), (50, 50, 80, 80)]\n// after\nbboxes = [[10, 10, 100, 100], [50, 50, 80, 80]]","handlingStrategy":"validation","validationCode":"def valid_boxes(data):\n    if not isinstance(data, list) or not data:\n        return False\n    first = data[0]\n    if isinstance(first, list):\n        return all(isinstance(b, (list, tuple)) and len(b) == 4 for b in data)\n    if isinstance(first, dict):\n        return all(\"bbox\" in b or _looks_like_bbox_keys(b) for b in data)\n    return False","typeGuard":"def is_box_list(data: list) -> bool:\n    return bool(data) and isinstance(data[0], (list, dict))","tryCatchPattern":"try:\n    boxes = normalize(data)\nexcept ValueError as e:\n    raise UserInputError(f\"bboxes rejected: {e}\") from e","preventionTips":["Always emit boxes as [[x, y, w, h], ...] lists, never tuples.","When producing element dicts, include a 'bbox' list key.","Validate the first element's type before wiring custom sources into the bboxes input."],"tags":["validation","bounding-boxes","input-format","comfyui"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}