{"record":{"id":"9555c53e22f5d224","repo":"sgl-project/sglang","slug":"lora-nickname-cannot-be-empty","errorCode":null,"errorMessage":"lora_nickname cannot be empty","messagePattern":"lora_nickname cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py","lineNumber":474,"sourceCode":"    ) -> Dict[str, Any]:\n        \"\"\"\n        Set a LoRA adapter for the specified transformer(s).\n\n        Args:\n            lora_nickname: The nickname of the adapter (required).\n            lora_path: Path to the LoRA adapter (local path or HF repo id).\n                      Required for the first load; optional if re-activating a cached nickname.\n            target: Which transformer(s) to apply the LoRA to. One of:\n                - \"all\": Apply to all transformers (default)\n                - \"transformer\": Apply only to the primary transformer (high noise for Wan2.2)\n                - \"transformer_2\": Apply only to transformer_2 (low noise for Wan2.2)\n                - \"critic\": Apply only to the critic model\n\n        Returns:\n            Dictionary containing the API response with status and message\n        \"\"\"\n        if not lora_nickname:\n            raise ValueError(\"lora_nickname cannot be empty\")\n\n        # Prepare request payload\n        payload: Dict[str, Any] = {\n            \"lora_nickname\": lora_nickname,\n            \"target\": target,\n        }\n\n        # Add optional lora_path if provided\n        if lora_path:\n            payload[\"lora_path\"] = lora_path\n\n        try:\n            response = requests.post(\n                f\"{self.base_url}/set_lora\",\n                json=payload,\n                headers=self.headers,\n                timeout=30,\n            )","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py#L456-L492","documentation":"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.","triggerScenarios":"Calling set_lora(lora_nickname=\"\") — often because a variable holding the nickname was never set or the ComfyUI dropdown left empty.","commonSituations":"Nickname typo'd as empty string; LoRA list not loaded before the call; unconfigured optional input passed through as None.","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."],"exampleFix":"// before\napi.set_lora(\"\")\n// after\nif lora_nickname:\n    api.set_lora(lora_nickname)\nelse:\n    print(\"no LoRA selected; skipping\")","handlingStrategy":"validation","validationCode":"loras = api.list_loras() if hasattr(api, 'list_loras') else None\nif loras is not None:\n    assert lora_nickname in {l['nickname'] for l in loras}","typeGuard":"def valid_nickname(name: str | None) -> bool:\n    return isinstance(name, str) and bool(name.strip())","tryCatchPattern":null,"preventionTips":["Populate nickname from the server's LoRA list, not free text.","Skip the set_lora call when no adapter is selected."],"tags":["validation","lora","empty-parameter","sgldiffusion"],"backgroundTag":"empty-required-parameter","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}