{"record":{"id":"194d10e9ed809763","repo":"sgl-project/sglang","slug":"shape-width-and-height-must-be-positive-finite-num","errorCode":null,"errorMessage":"shape width and height must be positive finite numbers","messagePattern":"shape width and height must be positive finite numbers","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/resolved_plan.py","lineNumber":133,"sourceCode":"    *,\n    width: int | float,\n    height: int | float,\n    base_short_edge: int = MINIMAX_H3_BASE_SHORT_EDGE,\n) -> dict[str, Any]:\n    \"\"\"Resolve one display ratio with the ``adapt_shape_v1`` math.\n\n    This is the only implementation of adaptive target geometry. Callers may\n    pass an explicit aspect-ratio pair or probed display dimensions; only the\n    ratio is significant. The supported ratio range is inclusive 1:4 to 4:1.\n    The returned dimensions are always 32px aligned; nearest-grid rounding may\n    leave the final area slightly above the pre-round soft pixel budget.\n    \"\"\"\n    base_short_edge = _validate_base_short_edge(base_short_edge)\n    try:\n        source_width = float(width)\n        source_height = float(height)\n    except (TypeError, ValueError) as exc:\n        raise ValueError(\n            \"shape width and height must be positive finite numbers\"\n        ) from exc\n    if (\n        not math.isfinite(source_width)\n        or not math.isfinite(source_height)\n        or source_width <= 0.0\n        or source_height <= 0.0\n    ):\n        raise ValueError(\"shape width and height must be positive finite numbers\")\n\n    ratio = source_width / source_height\n    if not math.isfinite(ratio) or ratio <= 0.0:\n        raise ValueError(\"shape ratio must be a positive finite number\")\n    if not MINIMAX_H3_MIN_ASPECT_RATIO <= ratio <= MINIMAX_H3_MAX_ASPECT_RATIO:\n        raise ValueError(\n            \"adapt_shape_v1 ratio must be within the inclusive range \"\n            f\"1:4 to 4:1, got {source_width:g}:{source_height:g}\"\n        )","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/resolved_plan.py#L115-L151","documentation":"The width/height passed to minimax_h3_resolve_spatial_shape must be convertible to float. This variant fires when float(width)/float(height) raises TypeError (None) or ValueError (a non-numeric string).","triggerScenarios":"Calling minimax_h3_resolve_spatial_shape with width=None or height='auto' — anything float() cannot parse.","commonSituations":"Passing an unresolved/deferred shape dict before probing actual media dimensions; a metadata probe failed and returned None.","solutions":["Probe the source media for real pixel dimensions first and pass numbers","Default/skip resolution when the probe returns None instead of forwarding it"],"exampleFix":"# before\nshape = resolve_spatial_shape(w=probe.get(\"width\"), h=probe.get(\"height\"), ...)\n# after\nif probe.get(\"width\") is None: raise RetryableProbeError(...)\nshape = resolve_spatial_shape(w=probe[\"width\"], h=probe[\"height\"], ...)","handlingStrategy":"validation","validationCode":"def dims_ok(w, h):\n    try: return float(w) > 0 and float(h) > 0\n    except (TypeError, ValueError): return False","typeGuard":"def is_valid_dims(w, h) -> bool:\n    try:\n        return float(w) > 0 and float(h) > 0\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":"null","preventionTips":["Never forward a failed media probe; re-probe or reject the asset"],"tags":["minimax-h3","spatial","type-error","dimensions"],"backgroundTag":"invalid-parameter-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}