{"record":{"id":"51451272868debb9","repo":"roboflow/supervision","slug":"colorpalette-must-contain-at-least-one-color","errorCode":null,"errorMessage":"ColorPalette must contain at least one color","messagePattern":"ColorPalette must contain at least one color","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/draw/color.py","lineNumber":558,"sourceCode":"\n        Args:\n            idx: Index of the color in the palette.\n\n        Returns:\n            Color at the given index.\n\n        Example:\n            ```pycon\n            >>> import supervision as sv\n            >>> colors = ['#ff0000', '#00ff00', '#0000ff']\n            >>> color_palette = sv.ColorPalette.from_hex(colors)\n            >>> color_palette.by_idx(1)\n            Color(r=0, g=255, b=0)\n\n            ```\n        \"\"\"\n        if not self.colors:\n            raise ValueError(\"ColorPalette must contain at least one color\")\n        # Modulo preserves Python-like wrapping for negative and oversized indexes.\n        idx = idx % len(self.colors)\n        return self.colors[idx]\n\n    def __len__(self) -> int:\n        \"\"\"\n        Returns the number of colors in the palette.\n\n        Returns:\n            The number of colors.\n        \"\"\"\n        return len(self.colors)\n\n\ndef unify_to_bgr(color: tuple[int, int, int] | Color) -> tuple[int, int, int]:\n    \"\"\"\n    Converts a color input in multiple formats to a standardized BGR format.\n","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/draw/color.py#L540-L576","documentation":"Error \"ColorPalette must contain at least one color\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/draw/color.py:558 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the ColorPalette with at least one Color.","Use a predefined palette such as ColorPalette.DEFAULT instead of an empty list."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}