sgl-project/sglang · error · ValueError
k_mode must not be empty
Error message
k_mode must not be empty
What it means
Raised by preprocess_dots_video when k_mode is an empty string. k_mode selects the model's key/mode preset for video preprocessing (default 'eval_ek') and cannot be blank.
Source
Thrown at python/sglang/srt/multimodal/processors/dots_note_omni.py:136
if last < len(user_value):
content.append({"type": "text", "text": user_value[last:]})
return content
def preprocess_dots_video(
raw_video,
question: str,
*,
tokenizer,
seq: int = 131072,
audio_cap: float = 1.0,
audio_sr: int = 16000,
k_mode: str = "eval_ek",
max_new_tokens: int = 0,
) -> list[dict[str, Any]]:
"""Return in-memory timestamp/image/audio content using the server tokenizer."""
if not k_mode:
raise ValueError("k_mode must not be empty")
video_bytes, video_id = _video_payload(raw_video)
cfg = _build_video_cfg(
seq=seq,
audio_cap=audio_cap,
audio_sr=audio_sr,
max_new_tokens=max_new_tokens,
)
from sglang.srt.multimodal.processors.dots_note_omni_video_core import (
flatten_runner,
)
from sglang.srt.multimodal.processors.dots_note_omni_video_core import (
preprocess as pp,
)
video_b64 = base64.b64encode(video_bytes).decode()
sample = {
"meta": {"video_0": video_b64},
"conversations": [{"from": "user", "value": f"<video_0>{question}"}],View on GitHub (pinned to 0132848349)
Solutions
- Omit k_mode from video_config to use the default 'eval_ek'
- Or set a valid mode string such as 'eval_ek'
- Sanitize config dicts to drop empty-string values before sending
Example fix
// before
video_config = {"k_mode": k_mode or ""}
// after
video_config = {"k_mode": k_mode} if k_mode else {} Defensive patterns
Strategy: validation
Validate before calling
cfg = {k: v for k, v in cfg.items() if v != ''} # drop empty strings
if 'k_mode' in cfg:
assert cfg['k_mode'], 'k_mode must be a non-empty string' Type guard
def valid_k_mode(cfg: dict) -> bool:
km = cfg.get('k_mode', 'eval_ek')
return isinstance(km, str) and len(km) > 0 Prevention
- Omit optional keys instead of sending empty strings
- Sanitize templated config dicts for blank values
When it happens
Trigger: Passing video_config={"k_mode": ""} (explicitly empty) in a video request; None falls back to the default, only '' fails the falsy check.
Common situations: Config templating code injects an empty string for an unset key (e.g. k_mode from an env var or YAML field left blank) instead of omitting it.
Related errors
- seq must be positive, got {seq}
- audio_cap must be non-negative, got {audio_cap}
- Video placeholder count does not match video_data: {len(vide
- Unsupported video input type: {type(video_file)}
- Attention backend '{selected_backend}' is not supported by t
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/6546d31ffa73cdc8.
Report an issue: GitHub.