sgl-project/sglang · error · ValueError
target.aspect_ratio components must be positive, got {value!
Error message
target.aspect_ratio components must be positive, got {value!r} What it means
Both integer components of target.aspect_ratio must be strictly positive. A parseable pair like '0:9' or '-16:9' fails this check because a zero/negative dimension is meaningless.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/resolved_plan.py:90
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(
f"target.short_edge must be an integer, got {value!r}"
) from exc
if short_edge != value or short_edge <= 0:
raise ValueError(f"target.short_edge must be a positive integer, got {value!r}")View on GitHub (pinned to 0132848349)
Solutions
- Fix the upstream computation so neither component is zero/negative
- Guard with a fallback like '1:1' when computed ratios are degenerate
Example fix
# before
aspect = f"{w}:{h}" # w==0
# after
aspect = f"{w or 1}:{h or 1}" Defensive patterns
Strategy: validation
Validate before calling
def parts_positive(v):
try: w, h = v.split(":"); return int(w) > 0 and int(h) > 0
except Exception: return False Type guard
def is_positive_ratio(v) -> bool:
try:
w, h = v.split(":"); return int(w) > 0 and int(h) > 0
except Exception:
return False Try / catch
null
Prevention
- Guard zero-dimension probes before formatting the ratio
When it happens
Trigger: Calling minimax_h3_resolve_plan with target.aspect_ratio such as '0:9', '-1:1', or computed values where one side evaluates to 0.
Common situations: Aspect ratio computed from a zero width/height upstream (e.g. failed probe defaults to 0) and rendered as '0:0'.
Related errors
- target.aspect_ratio must be 'W:H' or 'auto', got {value!r}
- target.aspect_ratio must be integer 'W:H', got {value!r}
- 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/e1f62073e2d0523e.
Report an issue: GitHub.