{"record":{"id":"e7ba2ce36575e1c3","repo":"roboflow/supervision","slug":"unsupported-flip-code-flip-code","errorCode":null,"errorMessage":"Unsupported flip code: {flip_code}","messagePattern":"Unsupported flip code: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/_cv2/_image.py","lineNumber":30,"sourceCode":"from supervision._cv2.constants import (\n    _BORDER_CONSTANT,\n    _IMREAD_COLOR,\n    _IMREAD_UNCHANGED,\n    _INTER_LINEAR,\n    _INTER_NEAREST,\n)\n\n\ndef _flip(image: npt.NDArray[Any], flip_code: int) -> npt.NDArray[Any]:\n    \"\"\"Flip an image vertically, horizontally, or along both axes.\"\"\"\n    if flip_code == 0:\n        axes: tuple[int, ...] = (0,)\n    elif flip_code == 1:\n        axes = (1,)\n    elif flip_code == -1:\n        axes = (0, 1)\n    else:\n        raise ValueError(f\"Unsupported flip code: {flip_code}\")\n    return np.ascontiguousarray(np.flip(image, axis=axes))\n\n\ndef _copy_make_border(\n    image: npt.NDArray[Any],\n    top: int,\n    bottom: int,\n    left: int,\n    right: int,\n    border_type: int,\n    value: int | float | Sequence[int | float] = 0,\n) -> npt.NDArray[Any]:\n    \"\"\"Add a constant border around an image.\"\"\"\n    if border_type != _BORDER_CONSTANT:\n        raise ValueError(\"Only BORDER_CONSTANT is supported by the fallback\")\n    if min(top, bottom, left, right) < 0:\n        raise ValueError(\"Border sizes must be non-negative\")\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/_cv2/_image.py#L12-L48","documentation":"The fallback cv2.flip maps flip_code 0 to vertical, 1 to horizontal, and -1 to both axes, mirroring OpenCV's only three documented codes. Any other integer has no meaning in np.flip terms and is rejected with this ValueError instead of producing an undefined result.","triggerScenarios":"Calling cv2.flip(image, flip_code) with flip_code not in {0, 1, -1}, e.g. 2, or a bool/None coerced to an unexpected int.","commonSituations":"Typos (flip code 2), flip_code read from config files with wrong values, or code assuming additional codes exist. Extremely rare in practice since the three-code contract is standard.","solutions":["Use 0 (vertical), 1 (horizontal), or -1 (both) — these are the only valid codes in OpenCV itself.","Validate config-supplied flip values against {0, 1, -1} at load time."],"exampleFix":"# before\nflipped = cv2.flip(frame, 2)\n\n# after\nflipped = cv2.flip(frame, -1)  # flip both axes","handlingStrategy":"validation","validationCode":"if flip_code not in (0, 1, -1):\n    raise ValueError(f'flip_code must be 0, 1, or -1, got {flip_code}')\nflipped = cv2.flip(image, flip_code)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only the three documented flip codes","Validate config-driven flip values at load time"],"tags":["opencv-fallback","flip","input-validation"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}