sgl-project/sglang · error · ValueError
invalid action segment {segment!r}; expected '<keys>-<frames
Error message
invalid action segment {segment!r}; expected '<keys>-<frames>' What it means
Raised by parse_sana_wm_action_string when a comma-separated segment is empty or contains no '-' separator. Each segment must follow '<keys>-<frames>', e.g. 'ab-4'.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py:128
if not isinstance(payload, list):
raise ValueError(f"{error_label} must be list[list[str]]")
out: list[list[str]] = []
for frame_actions in payload:
if not isinstance(frame_actions, list):
raise ValueError(f"{error_label} must be list[list[str]]")
out.append([str(key).lower() for key in frame_actions])
return out
def parse_sana_wm_action_string(action: str) -> list[list[str]]:
cleaned = "".join(action.replace(",", ",").split())
if not cleaned:
raise ValueError("action string is empty")
per_frame: list[list[str]] = []
for segment in cleaned.split(","):
if not segment or "-" not in segment:
raise ValueError(
f"invalid action segment {segment!r}; expected '<keys>-<frames>'"
)
keys_part, duration = segment.rsplit("-", 1)
if not duration.isdigit() or int(duration) <= 0:
raise ValueError(f"invalid duration in action segment {segment!r}")
if keys_part.lower() == "none":
keys: list[str] = []
else:
bad = sorted(
{
char
for char in keys_part.lower()
if char not in _SANA_WM_ALLOWED_ACTION_KEYS
}
)
if bad:
raise ValueError(View on GitHub (pinned to 0132848349)
Solutions
- Fix the segment to '<keys>-<frames>' form, e.g. 'ab-4'
- Strip trailing/duplicate commas before parsing: ','.join(s for s in cleaned.split(',') if s)
- Validate the format with a regex before handing to the pipeline
Example fix
// before action = 'forward-4,,left-2,' // after action = 'forward-4,left-2'
Defensive patterns
Strategy: validation
Validate before calling
import re
assert all(re.fullmatch(r'.+-.+', seg) for seg in cleaned.split(',') if seg) Type guard
def segments_wellformed(s: str) -> bool:
return all('-' in seg and seg for seg in ''.join(s.replace(',', ',')).split(',')) Prevention
- Strip trailing/double commas from user input before parsing
- Document the '<keys>-<frames>' grammar at the user-facing API
When it happens
Trigger: Action strings like 'ab4' (missing dash), 'ab-4,,cd-2' (empty segment from trailing/double comma), or 'ab-' / '-4' style malformed segments (though those fail the dash check only when no '-' exists at all).
Common situations: User-typed camera action strings missing the dash; trailing commas in config; LLM-generated action strings omitting the duration suffix.
Related errors
- action string is empty
- invalid duration in action segment {segment!r}
- unknown action keys {bad}; allowed keys are {sorted(_SANA_WM
- plucker_emb token count {plucker_emb.shape[1]} != latent tok
- chunk_size must be > 0, got {chunk_size}.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/28e11e7a5de0d409.
Report an issue: GitHub.