sgl-project/sglang · error · ValueError

Prompt cannot be empty

Error message

Prompt cannot be empty

What it means

ValueError raised by the ComfyUI SGLDiffusionGenerateImage node before any request is sent: positive_prompt is empty. It is a client-side precondition so users get a clear ComfyUI error instead of a server round-trip.

Source

Thrown at python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/nodes.py:351

    CATEGORY = "SGLDiffusion"
    OUTPUT_NODE = False

    def generate_image(
        self,
        sgld_client: SGLDiffusionServerAPI,
        positive_prompt: str,
        negative_prompt: str = "",
        image: torch.Tensor = None,
        seed: int = 1024,
        steps: int = 6,
        cfg: float = 7.0,
        width: int = 1024,
        height: int = 1024,
        enable_teacache: bool = False,
    ):
        """Generate image using SGLang Diffusion API."""
        if not positive_prompt:
            raise ValueError("Prompt cannot be empty")

        size = f"{width}x{height}"

        # Prepare request parameters
        request_params = {
            "prompt": positive_prompt,
            "size": size,
            "response_format": "b64_json",
        }

        # Add optional parameters if provided
        if negative_prompt:
            request_params["negative_prompt"] = negative_prompt
        if cfg is not None:
            request_params["guidance_scale"] = cfg
        if steps is not None:
            request_params["num_inference_steps"] = steps
        if seed is not None and seed >= 0:

View on GitHub (pinned to 0132848349)

Solutions

  1. Type a prompt into the text node or connect a CLIPTextEncode output to the positive input.
  2. Check for stray whitespace-only strings.
  3. If intentional blank generation is needed, supply a placeholder prompt.

Example fix

// before
# ComfyUI: positive prompt widget left empty
// after
positive_prompt = positive_prompt.strip() or "a scenic landscape, ultra detailed"
Defensive patterns

Strategy: validation

Validate before calling

if not positive_prompt or not positive_prompt.strip():
    raise ValueError('positive prompt required')

Type guard

def node_has_prompt(s: str | None) -> bool:
    return isinstance(s, str) and bool(s.strip())

Prevention

When it happens

Trigger: Executing the ComfyUI node with an empty/unconnected positive prompt text field.

Common situations: Text encode node not wired into the generator; empty STRING widget; workflow templating that clears prompts.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/1f5b303eb0a46292. Report an issue: GitHub.