sgl-project/sglang · error · ValueError
lora_nickname cannot be empty
Error message
lora_nickname cannot be empty
What it means
ValueError guard in SGLDiffusionServerAPI.set_lora: lora_nickname is empty/None. The LoRA hot-swap endpoint requires a nickname identifying which trained adapter to activate.
Source
Thrown at python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py:474
) -> Dict[str, Any]:
"""
Set a LoRA adapter for the specified transformer(s).
Args:
lora_nickname: The nickname of the adapter (required).
lora_path: Path to the LoRA adapter (local path or HF repo id).
Required for the first load; optional if re-activating a cached nickname.
target: Which transformer(s) to apply the LoRA to. One of:
- "all": Apply to all transformers (default)
- "transformer": Apply only to the primary transformer (high noise for Wan2.2)
- "transformer_2": Apply only to transformer_2 (low noise for Wan2.2)
- "critic": Apply only to the critic model
Returns:
Dictionary containing the API response with status and message
"""
if not lora_nickname:
raise ValueError("lora_nickname cannot be empty")
# Prepare request payload
payload: Dict[str, Any] = {
"lora_nickname": lora_nickname,
"target": target,
}
# Add optional lora_path if provided
if lora_path:
payload["lora_path"] = lora_path
try:
response = requests.post(
f"{self.base_url}/set_lora",
json=payload,
headers=self.headers,
timeout=30,
)View on GitHub (pinned to 0132848349)
Solutions
- Pass the exact nickname the adapter was registered under on the server.
- Fetch the server's LoRA list first and validate the nickname against it.
- Default empty inputs to a known adapter or skip the call entirely.
Example fix
// before
api.set_lora("")
// after
if lora_nickname:
api.set_lora(lora_nickname)
else:
print("no LoRA selected; skipping") Defensive patterns
Strategy: validation
Validate before calling
loras = api.list_loras() if hasattr(api, 'list_loras') else None
if loras is not None:
assert lora_nickname in {l['nickname'] for l in loras} Type guard
def valid_nickname(name: str | None) -> bool:
return isinstance(name, str) and bool(name.strip()) Prevention
- Populate nickname from the server's LoRA list, not free text.
- Skip the set_lora call when no adapter is selected.
When it happens
Trigger: Calling set_lora(lora_nickname="") — often because a variable holding the nickname was never set or the ComfyUI dropdown left empty.
Common situations: Nickname typo'd as empty string; LoRA list not loaded before the call; unconfigured optional input passed through as None.
Related errors
- LoRA batch_info must provide max_len or seg_lens.
- No image data in response
- Image index {index} out of range
- No base64 image data found
- Failed to set LoRA adapter: {str(e)}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/9555c53e22f5d224.
Report an issue: GitHub.