roboflow/supervision · error · ValueError

ColorPalette must contain at least one color

Error message

ColorPalette must contain at least one color

What it means

Error "ColorPalette must contain at least one color" thrown in roboflow/supervision.

Source

Thrown at src/supervision/draw/color.py:558

        Args:
            idx: Index of the color in the palette.

        Returns:
            Color at the given index.

        Example:
            ```pycon
            >>> import supervision as sv
            >>> colors = ['#ff0000', '#00ff00', '#0000ff']
            >>> color_palette = sv.ColorPalette.from_hex(colors)
            >>> color_palette.by_idx(1)
            Color(r=0, g=255, b=0)

            ```
        """
        if not self.colors:
            raise ValueError("ColorPalette must contain at least one color")
        # Modulo preserves Python-like wrapping for negative and oversized indexes.
        idx = idx % len(self.colors)
        return self.colors[idx]

    def __len__(self) -> int:
        """
        Returns the number of colors in the palette.

        Returns:
            The number of colors.
        """
        return len(self.colors)


def unify_to_bgr(color: tuple[int, int, int] | Color) -> tuple[int, int, int]:
    """
    Converts a color input in multiple formats to a standardized BGR format.

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Create the ColorPalette with at least one Color.
  2. Use a predefined palette such as ColorPalette.DEFAULT instead of an empty list.

When it happens

Trigger: Thrown at src/supervision/draw/color.py:558 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15). Data as JSON: /api/errors/51451272868debb9. Report an issue: GitHub.