{"record":{"id":"972246a77664ebcb","repo":"roboflow/supervision","slug":"module-name-has-no-attribute-name","errorCode":null,"errorMessage":"module {__name__} has no attribute {name}","messagePattern":"module (.+?) has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"src/supervision/__init__.py","lineNumber":317,"sourceCode":"    \"tint_image\",\n    \"xcycwh_to_xyxy\",\n    \"xywh_to_xyxy\",\n    \"xyxy_to_mask\",\n    \"xyxy_to_polygons\",\n    \"xyxy_to_xcycarh\",\n    \"xyxy_to_xywh\",\n    \"xyxyxyxy_to_xyxy\",\n]\n\n\ndef __getattr__(name: str) -> Any:\n    \"\"\"Lazily resolve deprecated compatibility exports.\"\"\"\n    if name == \"ByteTrack\":\n        from supervision.tracker.byte_tracker.core import ByteTrack as byte_track\n\n        globals()[name] = byte_track\n        return byte_track\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n","sourceCodeStart":299,"sourceCodeEnd":318,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/__init__.py#L299-L318","documentation":"Thrown by supervision's internal _validate_color_hex helper when a hex color string, after stripping a leading '#', contains valid hex characters but its length is not 3, 4, 6, or 8. The library only supports CSS-style shorthand (RGB, RGBA), 6-digit RRGGBB, and 8-digit RRGGBBAA forms. Any other length (e.g. 5 or 7 characters) is rejected before Color.from_hex can parse it.","triggerScenarios":"Calling sv.Color.from_hex('#FF000') (5 digits, a typo), sv.Color.from_hex('8000') expecting an 8-digit alpha color, passing sv.ColorPalette.from_hex(['#12345']) with a truncated hex, or building a palette from user/theme-supplied colors that use non-standard lengths like 12-digit hex.","commonSituations":"Typos in config files or UI color pickers feeding hex strings into annotator color arguments; copying colors from design tools that emit formats like '#RGBAA' variants or hex with alpha in unusual positions; converting numeric colors to hex with wrong padding (e.g. hex(255) -> 'ff' concatenated incorrectly producing odd lengths).","solutions":["Check the length of the hex string after removing '#': it must be exactly 3, 4, 6, or 8 characters, then fix the typo (most cases are a truncated or extra digit).","If you intended shorthand with alpha, use 4 digits (#RGBA) or the explicit 8-digit form #RRGGBBAA.","If generating hex programmatically, format with fixed width, e.g. f'#{value:06X}', and pad instead of truncating.","Wrap user-supplied colors in a small sanitizer that validates with a regex like ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$ before passing them to supervision."],"exampleFix":"# before\nsv.Color.from_hex('#FF000')  # 5 digits -> ValueError: Invalid length of color hash\n\n# after\nsv.Color.from_hex('#FF0000')  # 6-digit RRGGBB\nsv.Color.from_hex('#FF000080')  # 8-digit RRGGBBAA with alpha","handlingStrategy":"validation","validationCode":"import re\n\n_HEX_RE = re.compile(r\"^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$\")\n\ndef is_valid_color_hex(s: str) -> bool:\n    \"\"\"True if supervision's Color.from_hex will accept the string.\"\"\"\n    return bool(_HEX_RE.match(s))\n\n# before: sv.ColorPalette.from_hex(user_colors)\n# after:\n# assert all(is_valid_color_hex(c) for c in user_colors), user_colors","typeGuard":"def is_valid_color_hex(s: str) -> bool:\n    \"\"\"Narrow a str to one Color.from_hex accepts (3/4/6/8 hex digits).\"\"\"\n    return bool(re.match(r\"^#?[0-9a-fA-F]{3,8}$\", s)) and len(s.lstrip('#')) in (3, 4, 6, 8)","tryCatchPattern":"try:\n    color = sv.Color.from_hex(hex_str)\nexcept ValueError as e:\n    if 'color hash' in str(e):\n        logger.warning(\"dropping malformed color %r: %s\", hex_str, e)\n        color = sv.Color.DEFAULT\n    else:\n        raise","preventionTips":["Validate every hex string with a strict regex before it reaches supervision, especially colors from config files, databases, or user input.","When generating hex from numbers, always use fixed-width formatting (f'#{v:06X}') instead of string concatenation.","Prefer 6-digit #RRGGBB everywhere in your codebase to keep the format uniform and easy to lint."],"tags":["validation","color","hex","valueerror"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}