abi/screenshot-to-code · warning · HTTPException
At least one model is required
Error message
At least one model is required
What it means
400 raised by POST /run_evals_stream in backend/routes/evals.py:267 when the request body's models list is empty. At least one model must be selected to schedule evaluation tasks; the guard fires before any set/session resolution.
Source
Thrown at backend/routes/evals.py:267
if selected_files:
return len([f for f in selected_files if f in brief_ids])
return len(brief_ids)
if selected_files:
return len([f for f in selected_files if f.endswith(".png")])
if set_name:
return len(eval_sets.list_set_images(set_name))
input_dir = os.path.join(EVALS_DIR, "inputs")
return len([f for f in os.listdir(input_dir) if f.endswith(".png")])
@router.post("/run_evals_stream")
async def run_evals_stream(request: RunEvalsRequest):
"""Run evaluations and stream progress events as newline-delimited JSON."""
if not request.models:
raise HTTPException(status_code=400, detail="At least one model is required")
eval_set, session, skip_per_model = _resolve_set_run(request)
per_model_task_counts: Dict[str, int] = {}
per_model_skipped_existing: Dict[str, int] = {}
if request.diff_mode:
for model in request.models:
pending_tasks, skipped_tasks = count_pending_eval_tasks(
stack=request.stack,
model=model,
input_files=request.files,
n=N,
diff_mode=True,
eval_set=eval_set,
skip_input_files=skip_per_model.get(model),
)
per_model_task_counts[model] = pending_tasks
per_model_skipped_existing[model] = skipped_tasksView on GitHub (pinned to d026163f58)
Solutions
- Include at least one valid model name in the models array.
- Disable the run button in the UI until at least one model is selected.
- If no models appear selectable, check that an API key is configured (see the models the backend offers).
Example fix
// before
if (runRequested) startRun({ models: selectedModels, ... });
// after
if (selectedModels.length === 0) { toast('Select at least one model'); return; }
startRun({ models: selectedModels, ... }); Defensive patterns
Strategy: validation
Validate before calling
if (!Array.isArray(models) || models.length === 0) {
throw new Error('At least one model is required');
} Type guard
function hasModels(models: unknown): models is string[] {
return Array.isArray(models) && models.length > 0 && models.every(m => typeof m === 'string');
} Prevention
- Keep the run button disabled until a model is selected.
- If the model list is empty, check API-key configuration first.
When it happens
Trigger: POST /run_evals_stream with models: [] — e.g. the UI sent the request before any model checkbox was ticked, or a filter removed all models.
Common situations: Default model list empty due to missing API keys filtering out all models; race where the run button is enabled before model selection loads.
Related errors
- Invalid run id
- max_age_days must be >= 1
- Design system name is required
- Invalid eval set name: {set_name!r}
- Not a set image: {filename!r}
AI-assisted analysis of abi/screenshot-to-code@d026163f58 (2026-08-14).
Data as JSON: /api/errors/7596224e5ea6d9d1.
Report an issue: GitHub.