unslothai/unsloth · error · ValueError
every prompt in prompts must be non-empty
Error message
every prompt in prompts must be non-empty
What it means
Raised by the prompts field_validator on DiffusionGenerateRequest when any prompt in the batch list is empty or whitespace-only. Empty batch entries would generate garbage images from nothing, so they are rejected as a 422.
Source
Thrown at studio/backend/models/inference.py:2970
max_length = 32,
description = "Prompt list for batched generation: one image per prompt in a single "
"forward pass (plain text-to-image only). Overrides `prompt` for the images; "
"`prompt` is still required as the fallback/display value.",
)
seeds: Optional[list[int]] = Field(
None,
min_length = 1,
max_length = 32,
description = "Per-image seeds for batched generation: one image per seed (with "
"`prompts`, lengths must match; alone, every image uses `prompt`). Each image is "
"individually reproducible from its own seed.",
)
@field_validator("prompts")
@classmethod
def _non_empty_prompts(cls, value: Optional[list[str]]) -> Optional[list[str]]:
if value is not None and any(not p.strip() for p in value):
raise ValueError("every prompt in prompts must be non-empty")
return value
@field_validator("seeds")
@classmethod
def _seeds_json_safe(cls, value: Optional[list[int]]) -> Optional[list[int]]:
# Same JSON safe-integer bound as `seed`, so every per-image seed survives the gallery recipe.
if value is not None and any(s < 0 or s > 2**53 - 1 for s in value):
raise ValueError("every seed must be between 0 and 2**53 - 1")
return value
@model_validator(mode = "after")
def _prompts_seeds_lengths_match(self) -> "DiffusionGenerateRequest":
if (
self.prompts is not None
and self.seeds is not None
and len(self.prompts) != len(self.seeds)
):
raise ValueError(View on GitHub (pinned to 203007d190)
Solutions
- Filter or reject blank prompts client-side before submitting (see validationCode).
- Fix the batch source (CSV import) to skip empty rows.
- If a slot is intentionally unused, remove it — prompts and seeds lengths must match anyway.
Example fix
# before
payload = {"prompts": prompts_raw}
# after
prompts_clean = [p for p in prompts_raw if p and p.strip()]
payload = {"prompts": prompts_clean} Defensive patterns
Strategy: validation
Validate before calling
def clean_prompts(prompts: list[str] | None) -> list[str] | None:
if prompts is None:
return None
cleaned = [p for p in prompts if p and p.strip()]
if len(cleaned) != len(prompts):
raise ValueError('blank prompt in batch')
return cleaned Prevention
- Skip empty rows during CSV/spreadsheet import
- Reject submit when any batch row is blank
- Recompute the seeds list whenever prompts are filtered so lengths stay matched
When it happens
Trigger: POST /generate with prompts: ["a cat", "", " "}. Also when a batch UI submits one blank row among filled ones.
Common situations: Spreadsheet/CSV-driven batch generation with blank rows; front-ends that keep placeholder empty rows in the submitted list; trailing commas in JSON arrays yielding empty strings after client-side joins.
Related errors
- prompts and seeds must have the same length (got {len(self.p
- seed + batch_size - 1 must not exceed 2**53 - 1 so every per
- duplicate LoRA id '{spec.id}'; list each adapter at most onc
- guidance_start must be <= guidance_end
- every seed must be between 0 and 2**53 - 1
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/1f18d803c75e7c57.
Report an issue: GitHub.