abi/screenshot-to-code · error · HTTPException

Error reading input files: {str(e)}

Error message

Error reading input files: {str(e)}

What it means

500 raised by GET /eval_input_files in backend/routes/evals.py:50 when any exception escapes the directory scan of {EVALS_DIR}/inputs. In practice this is almost always FileNotFoundError because os.listdir(input_dir) is called without checking the directory exists; a permissions error produces the same wrapper.

Source

Thrown at backend/routes/evals.py:50

class InputFile(BaseModel):
    name: str
    path: str


@router.get("/eval_input_files", response_model=List[InputFile])
async def get_eval_input_files():
    """Get a list of all input files available for evaluations"""
    input_dir = os.path.join(EVALS_DIR, "inputs")
    try:
        files: list[InputFile] = []
        for filename in os.listdir(input_dir):
            if filename.endswith(".png"):
                file_path = os.path.join(input_dir, filename)
                files.append(InputFile(name=filename, path=file_path))
        return sorted(files, key=lambda x: x.name)
    except Exception as e:
        raise HTTPException(
            status_code=500, detail=f"Error reading input files: {str(e)}"
        )


@router.get("/evals", response_model=list[Eval])
async def get_evals(folder: str):
    if not folder:
        raise HTTPException(status_code=400, detail="Folder path is required")

    folder_path = Path(folder)
    if not folder_path.exists():
        raise HTTPException(status_code=404, detail=f"Folder not found: {folder}")

    try:
        evals: list[Eval] = []
        # Get all HTML files from folder
        files = {
            f: os.path.join(folder, f)

View on GitHub (pinned to d026163f58)

Solutions

  1. Create the inputs directory: mkdir -p backend/evals/inputs (relative to the backend working directory).
  2. Confirm the backend process runs from backend/ so the relative EVALS_DIR resolves correctly.
  3. Check directory permissions if it exists but is unreadable.

Example fix

# before
input_dir = os.path.join(EVALS_DIR, "inputs")
files: list[InputFile] = []
for filename in os.listdir(input_dir):
    ...

# after
input_dir = os.path.join(EVALS_DIR, "inputs")
if not os.path.isdir(input_dir):
    return []
files: list[InputFile] = []
for filename in os.listdir(input_dir):
    ...
Defensive patterns

Strategy: fallback

Validate before calling

# before calling, ensure the inputs dir exists from the backend side
import os
from config.config import EVALS_DIR
os.makedirs(os.path.join(EVALS_DIR, 'inputs'), exist_ok=True)

Try / catch

const res = await fetch('/eval_input_files');
if (res.status === 500) { files = []; /* treat as no inputs */ } else { files = await res.json(); }

Prevention

When it happens

Trigger: GET /eval_input_files when backend/evals/inputs does not exist (fresh clone, no eval inputs created yet), or the directory is unreadable due to permissions.

Common situations: New development environment where the evals/inputs folder was never populated; the working directory changed so EVALS_DIR points somewhere unexpected; CI running without the eval fixtures checked out.

Related errors


AI-assisted analysis of abi/screenshot-to-code@d026163f58 (2026-08-14). Data as JSON: /api/errors/235f91a0ec8e0c1b. Report an issue: GitHub.