{"record":{"id":"fb26823e98fd1433","repo":"abi/screenshot-to-code","slug":"folder-path-is-required","errorCode":null,"errorMessage":"Folder path is required","messagePattern":"Folder path is required","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"backend/routes/evals.py","lineNumber":58,"sourceCode":"    \"\"\"Get a list of all input files available for evaluations\"\"\"\n    input_dir = os.path.join(EVALS_DIR, \"inputs\")\n    try:\n        files: list[InputFile] = []\n        for filename in os.listdir(input_dir):\n            if filename.endswith(\".png\"):\n                file_path = os.path.join(input_dir, filename)\n                files.append(InputFile(name=filename, path=file_path))\n        return sorted(files, key=lambda x: x.name)\n    except Exception as e:\n        raise HTTPException(\n            status_code=500, detail=f\"Error reading input files: {str(e)}\"\n        )\n\n\n@router.get(\"/evals\", response_model=list[Eval])\nasync def get_evals(folder: str):\n    if not folder:\n        raise HTTPException(status_code=400, detail=\"Folder path is required\")\n\n    folder_path = Path(folder)\n    if not folder_path.exists():\n        raise HTTPException(status_code=404, detail=f\"Folder not found: {folder}\")\n\n    try:\n        evals: list[Eval] = []\n        # Get all HTML files from folder\n        files = {\n            f: os.path.join(folder, f)\n            for f in os.listdir(folder)\n            if f.endswith(\".html\")\n        }\n\n        # Extract base names\n        base_names: Set[str] = set()\n        for filename in files.keys():\n            base_name = (","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/routes/evals.py#L40-L76","documentation":"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.","triggerScenarios":"Calling GET /evals with no ?folder= query parameter, or with ?folder= (empty value).","commonSituations":"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.","solutions":["Pass a non-empty folder path: GET /evals?folder=/abs/path/to/output/folder.","Fix the caller to only issue the request after the user selects an output folder.","Use GET /eval_output_folders first to obtain valid folder paths."],"exampleFix":"// before\nconst url = `/evals?folder=${selectedFolder}`; // selectedFolder may be ''\n\n// after\nif (!selectedFolder) throw new Error('Select an output folder first');\nconst url = `/evals?folder=${encodeURIComponent(selectedFolder)}`;","handlingStrategy":"type-guard","validationCode":"if (!folder || !folder.trim()) throw new Error('folder is required');\nconst url = `/evals?folder=${encodeURIComponent(folder)}`;","typeGuard":"function hasFolder(folder: unknown): folder is string {\n  return typeof folder === 'string' && folder.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Gate the request on a non-empty selected folder.","Encode query parameters with encodeURIComponent."],"tags":["http-400","validation","query-params","fastapi"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}