{"record":{"id":"5e730bdc1ddce854","repo":"sgl-project/sglang","slug":"target-short-edge-must-be-a-positive-integer-got","errorCode":null,"errorMessage":"target.short_edge must be a positive integer, got {value!r}","messagePattern":"target\\.short_edge must be a positive integer, got (.+?)","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":108,"sourceCode":"        raise ValueError(\n            f\"target.aspect_ratio components must be positive, got {value!r}\"\n        )\n    return w, h\n\n\ndef _nearest_multiple(value: float, multiple: int) -> int:\n    return max(multiple, int(round(float(value) / multiple)) * multiple)\n\n\ndef _validate_base_short_edge(value: Any) -> int:\n    try:\n        short_edge = int(value)\n    except (TypeError, ValueError) as exc:\n        raise ValueError(\n            f\"target.short_edge must be an integer, got {value!r}\"\n        ) from exc\n    if short_edge != value or short_edge <= 0:\n        raise ValueError(f\"target.short_edge must be a positive integer, got {value!r}\")\n    if short_edge != MINIMAX_H3_BASE_SHORT_EDGE:\n        warn_unverified_short_edge(short_edge)\n    return short_edge\n\n\ndef minimax_h3_resolve_spatial_shape(\n    *,\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.","sourceCodeStart":90,"sourceCodeEnd":126,"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#L90-L126","documentation":"base_short_edge must be a positive integer and exactly integral — the check `short_edge != value` rejects floats like 512.5 and booleans, and `<= 0` rejects zero/negative values.","triggerScenarios":"Calling minimax_h3_resolve_spatial_shape with base_short_edge=512.5, 0, -64, or True (bool compares equal to 1 but the equality/positivity logic plus intent fails for fractional/zero values).","commonSituations":"Dividing a configured edge by 2 or a scale factor producing a .5 float; passing a scaled-down value that rounds to 0.","solutions":["Round/ceil the computed short edge to a whole positive integer","Ensure scale factors can't drive it to zero"],"exampleFix":"# before\nedge = base_edge * scale  # 256.5\n# after\nedge = max(1, round(base_edge * scale))","handlingStrategy":"validation","validationCode":"def edge_ok(v):\n    try: return int(v) == v and int(v) > 0\n    except (TypeError, ValueError): return False","typeGuard":"def is_valid_short_edge(v) -> bool:\n    try: return int(v) == v and int(v) > 0\n    except (TypeError, ValueError): return False","tryCatchPattern":"null","preventionTips":["round() scaled edges; clamp to >= 1"],"tags":["minimax-h3","short-edge","integer-validation","spatial"],"backgroundTag":"invalid-parameter-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}