{"record":{"id":"5625313224fdd5a6","repo":"roboflow/supervision","slug":"unsupported-color-lookup-strategy-color-lookup","errorCode":null,"errorMessage":"Unsupported color lookup strategy: {color_lookup}","messagePattern":"Unsupported color lookup strategy: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/annotators/utils.py","lineNumber":75,"sourceCode":"        return detection_idx\n    elif color_lookup == ColorLookup.CLASS:\n        if detections.class_id is None:\n            raise ValueError(\n                \"Could not resolve color by class because \"\n                \"Detections do not have class_id. If using an annotator, \"\n                \"try setting color_lookup to sv.ColorLookup.INDEX or \"\n                \"sv.ColorLookup.TRACK.\"\n            )\n        return int(detections.class_id[detection_idx])\n    elif color_lookup == ColorLookup.TRACK:\n        if detections.tracker_id is None:\n            raise ValueError(\n                \"Could not resolve color by track because \"\n                \"Detections do not have tracker_id. Did you call \"\n                \"tracker.update_with_detections(...) before annotating?\"\n            )\n        return int(detections.tracker_id[detection_idx])\n    raise ValueError(f\"Unsupported color lookup strategy: {color_lookup}\")\n\n\ndef resolve_text_background_xyxy(\n    center_coordinates: tuple[int, int],\n    text_wh: tuple[int, int],\n    position: Position,\n) -> tuple[int, int, int, int]:\n    \"\"\"Compute the background box for text anchored at `position`.\"\"\"\n    center_x, center_y = center_coordinates\n    text_w, text_h = text_wh\n\n    if position == Position.TOP_LEFT:\n        return center_x, center_y - text_h, center_x + text_w, center_y\n    elif position == Position.TOP_RIGHT:\n        return center_x - text_w, center_y - text_h, center_x, center_y\n    elif position == Position.TOP_CENTER:\n        return (\n            center_x - text_w // 2,","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/annotators/utils.py#L57-L93","documentation":"Raised by resolve_color_idx() in supervision.annotators.utils when the `color_lookup` argument is not a np.ndarray, and not one of the ColorLookup enum values INDEX, CLASS, or TRACK. This is the final fall-through raise after the CLASS and TRACK branches, so it fires only for genuinely unrecognized strategies — typically a typo'd string or a custom enum member.","triggerScenarios":"Passing color_lookup='index' (lowercase string) instead of sv.ColorLookup.INDEX; passing a custom ColorLookup subclass member; passing an int or None where the enum is expected.","commonSituations":"Constructing annotators from YAML/JSON config where the string is not converted to the enum; newer supervision versions adding enum members unknown to older code paths; copy-paste of raw strings from docs.","solutions":["Use the enum: color_lookup=sv.ColorLookup.INDEX / CLASS / TRACK.","When loading from config, map strings explicitly: {'INDEX': sv.ColorLookup.INDEX, ...}[raw.upper()].","If you need per-detection colors, pass a NumPy int array instead of an enum value.","Upgrade supervision if you intended a newly introduced lookup mode."],"exampleFix":"// before\nannotator = sv.BoxAnnotator(color_lookup='index')\n\n// after\nannotator = sv.BoxAnnotator(color_lookup=sv.ColorLookup.INDEX)","handlingStrategy":"validation","validationCode":"valid = set(sv.ColorLookup.list())\nassert color_lookup in valid or isinstance(color_lookup, np.ndarray), color_lookup","typeGuard":"def is_valid_color_lookup(value: object) -> bool:\n    return isinstance(value, np.ndarray) or (\n        isinstance(value, sv.ColorLookup) and value.value in sv.ColorLookup.list()\n    )","tryCatchPattern":"try:\n    annotator.annotate(scene, detections)\nexcept ValueError as e:\n    if 'color lookup' in str(e):\n        annotator.color_lookup = sv.ColorLookup.INDEX\n    raise","preventionTips":["Always pass sv.ColorLookup enum members, never raw strings.","Map config strings to enums via an explicit lookup table at load time."],"tags":["annotators","enum","configuration","validation"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}