{"record":{"id":"193710bbe6ec3732","repo":"sgl-project/sglang","slug":"prompt-cannot-be-empty","errorCode":null,"errorMessage":"Prompt cannot be empty","messagePattern":"Prompt cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py","lineNumber":112,"sourceCode":"            height: Image height (used if size is not provided)\n            n: Number of images to generate (1-10)\n            negative_prompt: Negative prompt to avoid certain elements\n            guidance_scale: Classifier-free guidance scale\n            num_inference_steps: Number of denoising steps\n            seed: Random seed for reproducible generation\n            enable_teacache: Enable TEA cache acceleration\n            response_format: Response format (\"b64_json\" or \"url\")\n            quality: Image quality (\"auto\", \"standard\", \"hd\") - only for generation\n            style: Image style (\"vivid\" or \"natural\") - only for generation\n            background: Background type (\"auto\", \"transparent\", \"opaque\")\n            output_format: Output format (\"png\", \"jpeg\", \"webp\")\n            generator_device: Device for random generator (\"cuda\" or \"cpu\")\n\n        Returns:\n            Dictionary containing the API response with generated/edited image data\n        \"\"\"\n        if not prompt:\n            raise ValueError(\"Prompt cannot be empty\")\n\n        # Determine size\n        if size is None:\n            if width is not None and height is not None:\n                size = f\"{width}x{height}\"\n            else:\n                size = \"1024x1024\"\n\n        # Build common parameters\n        common_params = self._build_image_common_params(\n            prompt=prompt,\n            size=size,\n            n=n,\n            response_format=response_format,\n            negative_prompt=negative_prompt,\n            guidance_scale=guidance_scale,\n            num_inference_steps=num_inference_steps,\n            seed=seed,","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py#L94-L130","documentation":"generate_image validates that the prompt is non-empty before making any request, raising ValueError immediately for empty or None prompts since the backend requires a text prompt for generation or editing.","triggerScenarios":"Calling generate_image(\"\") or generate_image(None), or passing a variable that was supposed to be populated from user input/configuration but ended up empty.","commonSituations":"UI code forwarding an empty text box, templating bugs producing empty strings, or scripted batches where some rows have blank prompt fields.","solutions":["Default or check the prompt before calling: prompt = prompt or fallback_text","Skip empty rows in batch loops: if not prompt.strip(): continue","Fix the upstream code that produces the empty prompt"],"exampleFix":"# before\nclient.generate_image(\"\")\n\n# after\nprompt = prompt.strip() or \"a scenic landscape\"\nclient.generate_image(prompt)","handlingStrategy":"validation","validationCode":"if not prompt or not prompt.strip():\n    raise ValueError(\"prompt required\")\nclient.generate_image(prompt.strip())","typeGuard":"def has_prompt(p: str | None) -> bool:\n    return isinstance(p, str) and bool(p.strip())","tryCatchPattern":null,"preventionTips":["Strip and assert prompts at the UI boundary","Skip blank rows in batch jobs"],"tags":["validation","prompt","image-generation"],"backgroundTag":"empty-required-input","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}