Comfy-Org/ComfyUI · error · ValueError

bboxes list must contain bounding boxes or elements, got {ty

Error message

bboxes list must contain bounding boxes or elements, got {type(first).__name__}

What it means

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.

Source

Thrown at comfy_extras/nodes_bounding_boxes.py:271

    if not isinstance(data, list):
        raise ValueError(
            "bboxes input must be bounding boxes, elements, or a JSON string, "
            f"got {type(data).__name__}"
        )
    if not data:
        return []
    first = data[0]
    if isinstance(first, list):
        return normalize_incoming_boxes(data)
    if isinstance(first, dict):
        if _looks_like_element(first):
            return elements_to_boxes(data, width, height)
        if _looks_like_bbox(first):
            return normalize_incoming_boxes(data)
        raise ValueError(
            "bboxes items must be bounding boxes (x, y, width, height) or elements (with a 'bbox')"
        )
    raise ValueError(
        f"bboxes list must contain bounding boxes or elements, got {type(first).__name__}"
    )


def _norm_bbox(region: dict) -> list[int]:
    def grid(value: float) -> int:
        return max(0, min(1000, round(value * 1000)))

    x, y = region.get("x", 0.0), region.get("y", 0.0)
    w, h = region.get("w", 0.0), region.get("h", 0.0)
    ymin, xmin, ymax, xmax = grid(y), grid(x), grid(y + h), grid(x + w)
    if ymin > ymax:
        ymin, ymax = ymax, ymin
    if xmin > xmax:
        xmin, xmax = xmax, xmin
    return [ymin, xmin, ymax, xmax]

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Convert tuple boxes to lists: pass [[x, y, w, h], ...] instead of [(x, y, w, h), ...].
  2. If sending JSON as text, make sure it parses to a list of [x, y, width, height] arrays before it reaches this node.
  3. Feed element dicts that include a 'bbox' key (e.g. results of layout-detection nodes) if you have elements rather than raw boxes.
  4. Check the upstream node's output type in the workflow; rewire through a node that emits list-of-list boxes.

Example fix

// before
bboxes = [(10, 10, 100, 100), (50, 50, 80, 80)]
// after
bboxes = [[10, 10, 100, 100], [50, 50, 80, 80]]
Defensive patterns

Strategy: validation

Validate before calling

def valid_boxes(data):
    if not isinstance(data, list) or not data:
        return False
    first = data[0]
    if isinstance(first, list):
        return all(isinstance(b, (list, tuple)) and len(b) == 4 for b in data)
    if isinstance(first, dict):
        return all("bbox" in b or _looks_like_bbox_keys(b) for b in data)
    return False

Type guard

def is_box_list(data: list) -> bool:
    return bool(data) and isinstance(data[0], (list, dict))

Try / catch

try:
    boxes = normalize(data)
except ValueError as e:
    raise UserInputError(f"bboxes rejected: {e}") from e

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/040990b1ff95fd1f. Report an issue: GitHub.