{"record":{"id":"235f91a0ec8e0c1b","repo":"abi/screenshot-to-code","slug":"error-reading-input-files-str-e","errorCode":null,"errorMessage":"Error reading input files: {str(e)}","messagePattern":"Error reading input files: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/routes/evals.py","lineNumber":50,"sourceCode":"\nclass InputFile(BaseModel):\n    name: str\n    path: str\n\n\n@router.get(\"/eval_input_files\", response_model=List[InputFile])\nasync def get_eval_input_files():\n    \"\"\"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)","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/routes/evals.py#L32-L68","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Create the inputs directory: mkdir -p backend/evals/inputs (relative to the backend working directory).","Confirm the backend process runs from backend/ so the relative EVALS_DIR resolves correctly.","Check directory permissions if it exists but is unreadable."],"exampleFix":"# before\ninput_dir = os.path.join(EVALS_DIR, \"inputs\")\nfiles: list[InputFile] = []\nfor filename in os.listdir(input_dir):\n    ...\n\n# after\ninput_dir = os.path.join(EVALS_DIR, \"inputs\")\nif not os.path.isdir(input_dir):\n    return []\nfiles: list[InputFile] = []\nfor filename in os.listdir(input_dir):\n    ...","handlingStrategy":"fallback","validationCode":"# before calling, ensure the inputs dir exists from the backend side\nimport os\nfrom config.config import EVALS_DIR\nos.makedirs(os.path.join(EVALS_DIR, 'inputs'), exist_ok=True)","typeGuard":null,"tryCatchPattern":"const res = await fetch('/eval_input_files');\nif (res.status === 500) { files = []; /* treat as no inputs */ } else { files = await res.json(); }","preventionTips":["Create evals/inputs as part of backend startup or repo scaffolding.","Run the backend from the backend/ directory so EVALS_DIR is stable."],"tags":["http-500","filesystem","evals","fastapi"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}