abi/screenshot-to-code · warning · HTTPException

Folder path is required

Error message

Folder path is required

What it means

400 raised by GET /evals in backend/routes/evals.py:58 when the required folder query parameter is missing or empty. FastAPI treats folder as an optional query string here, so the handler validates it manually and rejects empty requests before touching the filesystem.

Source

Thrown at backend/routes/evals.py:58

    """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)
            for f in os.listdir(folder)
            if f.endswith(".html")
        }

        # Extract base names
        base_names: Set[str] = set()
        for filename in files.keys():
            base_name = (

View on GitHub (pinned to d026163f58)

Solutions

  1. Pass a non-empty folder path: GET /evals?folder=/abs/path/to/output/folder.
  2. Fix the caller to only issue the request after the user selects an output folder.
  3. Use GET /eval_output_folders first to obtain valid folder paths.

Example fix

// before
const url = `/evals?folder=${selectedFolder}`; // selectedFolder may be ''

// after
if (!selectedFolder) throw new Error('Select an output folder first');
const url = `/evals?folder=${encodeURIComponent(selectedFolder)}`;
Defensive patterns

Strategy: type-guard

Validate before calling

if (!folder || !folder.trim()) throw new Error('folder is required');
const url = `/evals?folder=${encodeURIComponent(folder)}`;

Type guard

function hasFolder(folder: unknown): folder is string {
  return typeof folder === 'string' && folder.trim().length > 0;
}

Prevention

When it happens

Trigger: Calling GET /evals with no ?folder= query parameter, or with ?folder= (empty value).

Common situations: Frontend builds the URL from a variable that is undefined/empty before an output folder is selected; curl/manual testing that forgets the query param.

Related errors


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