{"record":{"id":"edb4379188e3fe8b","repo":"roboflow/supervision","slug":"both-dimensions-in-resolution-must-be-positive-go","errorCode":null,"errorMessage":"Both dimensions in resolution must be positive. Got ({w}, {h}).","messagePattern":"Both dimensions in resolution must be positive\\. Got \\((.+?), (.+?)\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/validators/__init__.py","lineNumber":351,"sourceCode":"\ndef _validate_resolution(resolution: Any) -> tuple[int, int]:\n    if not (isinstance(resolution, tuple) and len(resolution) == 2):\n        raise ValueError(\n            f\"\"\"\n            resolution must be a tuple of two integers, got\n            {type(resolution)} with value {resolution}\n            \"\"\"\n        )\n    w, h = resolution\n    if not (isinstance(w, int) and isinstance(h, int)):\n        raise ValueError(\n            f\"\"\"\n            Both elements in resolution must be integers.\n            Got types ({type(w)}, {type(h)})\n            \"\"\"\n        )\n    if w <= 0 or h <= 0:\n        raise ValueError(\n            f\"Both dimensions in resolution must be positive. Got ({w}, {h}).\"\n        )\n    return w, h\n\n\n@deprecated(  # type: ignore[untyped-decorator]\n    target=_validate_resolution,\n    deprecated_in=\"0.29.0\",\n    remove_in=\"0.32.0\",\n)\ndef validate_resolution(resolution: Any) -> tuple[int, int]:\n    return void(resolution)  # type: ignore[no-any-return]\n","sourceCodeStart":333,"sourceCodeEnd":364,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/validators/__init__.py#L333-L364","documentation":"Raised by supervision.validators._validate_resolution when both elements are ints but one is zero or negative. Pixel dimensions must be strictly positive; zero/negative resolution would make any downstream canvas or geometry math invalid.","triggerScenarios":"Passing resolution=(0, 1080), resolution=(-1920, 1080), or a resolution computed as w - margin where margin >= w.","commonSituations":"Arithmetic underflow when downscaling (int(w * 0) from a bad scale factor); passing through a zero-dimension video stream or an unreadable frame; sign errors from signed offsets.","solutions":["Guard computed dimensions: resolution=(max(1, w), max(1, h)).","Check your scale factor is > 0 before applying it.","Log/inspect frame dimensions before constructing resolution-dependent objects if streams may be malformed."],"exampleFix":"# before\nresolution = (int(w * scale), int(h * scale))  # scale == 0.0 -> (0, 0)\n\n# after\nassert scale > 0\nresolution = (max(1, int(w * scale)), max(1, int(h * scale)))","handlingStrategy":"validation","validationCode":"w, h = int(resolution[0]), int(resolution[1])\nif w <= 0 or h <= 0:\n    raise ValueError(f\"resolution must be positive, got ({w}, {h})\")\nobj = SomeAPI(resolution=(w, h))","typeGuard":"def is_positive_resolution(resolution: tuple[int, int]) -> bool:\n    return resolution[0] > 0 and resolution[1] > 0","tryCatchPattern":null,"preventionTips":["Clamp computed dimensions with max(1, value).","Assert scale factors are > 0 before applying them to dimensions.","Reject unreadable/zero-size frames before deriving resolution."],"tags":["resolution","validation","configuration","video"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}