abi/screenshot-to-code · error · ValueError
Prompt item {index} is missing a prompt string.
Error message
Prompt item {index} is missing a prompt string. What it means
ValueError("Prompt item {index} is missing a prompt string.") raised by load_prompts() when an array element is a dict but its "prompt" key is absent, not a string, or a blank/whitespace-only string. The check is isinstance(prompt, str) and prompt.strip(), so empty prompts are rejected too. Aborts the eval run at load time.
Source
Thrown at backend/run_image_generation_evals.py:83
prompts: list[PromptItem] = []
for index, item in enumerate(cast(list[Any], raw), start=1):
if isinstance(item, str):
prompts.append(
{
"id": f"{index:03d}",
"category": "Prompt",
"prompt": item,
}
)
continue
if not isinstance(item, dict):
raise ValueError(f"Prompt item {index} must be a string or object.")
item_dict = cast(dict[str, Any], item)
prompt = item_dict.get("prompt")
if not isinstance(prompt, str) or not prompt.strip():
raise ValueError(f"Prompt item {index} is missing a prompt string.")
prompt_id = item_dict.get("id")
category = item_dict.get("category")
prompts.append(
{
"id": prompt_id if isinstance(prompt_id, str) else f"{index:03d}",
"category": category if isinstance(category, str) else "Prompt",
"prompt": prompt,
}
)
return prompts
def build_replicate_input(
model: ReplicateEvalModel, prompt: str
) -> dict[str, str | int | float | bool]:
if model == "flux_2_klein":View on GitHub (pinned to d026163f58)
Solutions
- At the reported index, ensure the object has "prompt": "<non-empty text>" spelled exactly lowercase
- If the key was typo'd ("text"/"Prompt"), rename it to "prompt"
- Drop or fill empty-prompt rows before exporting the file
Example fix
// before
[{"id": "p1", "text": "a cat"}]
// after
[{"id": "p1", "prompt": "a cat"}] Defensive patterns
Strategy: validation
Validate before calling
def validate_prompt_objects(items: list) -> list[int]:
bad = []
for i, item in enumerate(items, start=1):
if isinstance(item, dict):
p = item.get("prompt")
if not isinstance(p, str) or not p.strip():
bad.append(i)
return bad Type guard
from typing import Any, TypeGuard
def has_valid_prompt(item: dict[str, Any]) -> TypeGuard[dict[str, Any]]:
p = item.get("prompt")
return isinstance(p, str) and bool(p.strip()) Try / catch
try:
load_prompts(prompt_file)
except ValueError as e:
if "missing a prompt string" in str(e):
idx = int(str(e).split()[2])
fill_or_drop_prompt(prompt_file, idx) Prevention
- Use exactly the lowercase key "prompt"; the loader is case-sensitive
- Reject empty/whitespace prompt cells when exporting from spreadsheets
- Prefer plain-string array elements unless you need id/category metadata
When it happens
Trigger: Array elements like {"id": "p1", "category": "Landscape"} (no prompt key), {"prompt": 123}, or {"prompt": " "}.
Common situations: Prompt objects built from spreadsheets/CSV where the prompt column is empty for some rows; typo'd key such as "text" or "Prompt" instead of "prompt" (keys are case-sensitive).
Related errors
- Prompt file must contain a JSON array.
- Prompt item {index} must be a string or object.
- Invalid brief entry in {set_name}: id={brief_id!r}
- No stack was provided
- No model was provided
AI-assisted analysis of abi/screenshot-to-code@d026163f58 (2026-08-14).
Data as JSON: /api/errors/ee0690c3d9bd41fb.
Report an issue: GitHub.