sgl-project/sglang · error · ValueError
target.aspect_ratio must be integer 'W:H', got {value!r}
Error message
target.aspect_ratio must be integer 'W:H', got {value!r} What it means
After splitting target.aspect_ratio on ':', both components must parse as integers. This error fires when int() raises — i.e. either side is non-numeric like '16:9.5', 'a:b', or '16:'.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/resolved_plan.py:86
materials: tuple[MiniMaxH3MaterialPlanItem, ...]
encoders: dict
branches: tuple[dict, ...]
default_flow_shift: float
default_audio_flow_shift: float
flow_shift: float | None
audio_flow_shift: float | None
shape: dict
condition_mask: dict
def _parse_aspect_ratio(value: str) -> tuple[int, int]:
parts = value.split(":")
if len(parts) != 2:
raise ValueError(f"target.aspect_ratio must be 'W:H' or 'auto', got {value!r}")
try:
w, h = int(parts[0]), int(parts[1])
except ValueError as exc:
raise ValueError(
f"target.aspect_ratio must be integer 'W:H', got {value!r}"
) from exc
if w <= 0 or h <= 0:
raise ValueError(
f"target.aspect_ratio components must be positive, got {value!r}"
)
return w, h
def _nearest_multiple(value: float, multiple: int) -> int:
return max(multiple, int(round(float(value) / multiple)) * multiple)
def _validate_base_short_edge(value: Any) -> int:
try:
short_edge = int(value)
except (TypeError, ValueError) as exc:
raise ValueError(View on GitHub (pinned to 0132848349)
Solutions
- Use integer components: '191:100' instead of '1.91:1'
- Validate the string with a regex like ^\d+:\d+$ before submitting
Example fix
// before "aspect_ratio":"1.91:1" // after "aspect_ratio":"191:100"
Defensive patterns
Strategy: validation
Validate before calling
import re def ratio_ok(v): return isinstance(v, str) and re.fullmatch(r"\d+:\d+", v) is not None
Type guard
def is_int_ratio(v) -> bool:
import re
return isinstance(v, str) and bool(re.fullmatch(r"-?\d+:-?\d+", v)) Try / catch
null
Prevention
- Expand decimals to integer pairs ('1.91:1' -> '191:100')
When it happens
Trigger: Calling minimax_h3_resolve_plan with target.aspect_ratio containing a float, empty component, or non-numeric text on either side of the colon.
Common situations: Supplying '1.91:1' (common cinematic notation) instead of an integer pair; trailing whitespace or empty component after a typo'd colon.
Related errors
- target.aspect_ratio must be 'W:H' or 'auto', got {value!r}
- target.aspect_ratio components must be positive, got {value!
- reference image ratio must be within the inclusive range 1:4
- {path}.aspect_ratio must be "auto" for task {profile.task!r}
- {path}.aspect_ratio for task {profile.task!r} must be 'auto'
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/6235dbe9fdf50fea.
Report an issue: GitHub.