abi/screenshot-to-code · error · HTTPException
Error reading output folders: {str(e)}
Error message
Error reading output folders: {str(e)} What it means
500 raised by the output-folders listing endpoint (GET /eval_output_folders) in backend/routes/evals.py:505 as a catch-all around os.listdir of the evals directory, getmtime, and sorting. Like error 63 it is typically FileNotFoundError when the evals root does not exist, or PermissionError on unreadable entries.
Source
Thrown at backend/routes/evals.py:505
"""Get a list of all output folders available for evaluations, sorted by recently modified"""
output_dir = os.path.join(EVALS_DIR, "results")
try:
folders: list[OutputFolder] = []
for folder_name in os.listdir(output_dir):
folder_path = os.path.join(output_dir, folder_name)
if os.path.isdir(folder_path) and not folder_name.startswith("."):
# Get modification time
modified_time = os.path.getmtime(folder_path)
folders.append(
OutputFolder(
name=folder_name, path=folder_path, modified_time=modified_time
)
)
# Sort by modified time, most recent first
return sorted(folders, key=lambda x: x.modified_time, reverse=True)
except Exception as e:
raise HTTPException(
status_code=500, detail=f"Error reading output folders: {str(e)}"
)
View on GitHub (pinned to d026163f58)
Solutions
- Create the evals directory: mkdir -p backend/evals.
- Ensure the backend runs from the backend/ directory so EVALS_DIR resolves as expected.
- If intermittent, stop concurrent deletion jobs while listing, or retry once.
Defensive patterns
Strategy: fallback
Validate before calling
# backend-side: ensure the directory exists before the endpoint is called import os from config.config import EVALS_DIR os.makedirs(EVALS_DIR, exist_ok=True)
Try / catch
const res = await fetch('/eval_output_folders');
const folders = res.ok ? await res.json() : []; // degrade to empty list Prevention
- Create the evals root during backend startup.
- Retry once on 500 — TOCTOU races with cleanup jobs are transient.
When it happens
Trigger: Calling the endpoint when {EVALS_DIR} does not exist (fresh checkout with no eval outputs), or when an entry inside disappeared between listdir and getmtime (TOCTOU), or is unreadable.
Common situations: Fresh clone without the backend/evals directory; cleanup job deleting folders mid-scan; wrong backend working directory.
Related errors
- Error reading input files: {str(e)}
- Error processing evals: {str(e)}
- Folder not found: {folder}
- Text eval set not found: {set_name}
- Unreadable briefs.json for {set_name}: {exc}
AI-assisted analysis of abi/screenshot-to-code@d026163f58 (2026-08-14).
Data as JSON: /api/errors/679f2003a927fd3b.
Report an issue: GitHub.