{"record":{"id":"679f2003a927fd3b","repo":"abi/screenshot-to-code","slug":"error-reading-output-folders-str-e","errorCode":null,"errorMessage":"Error reading output folders: {str(e)}","messagePattern":"Error reading output folders: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/routes/evals.py","lineNumber":505,"sourceCode":"    \"\"\"Get a list of all output folders available for evaluations, sorted by recently modified\"\"\"\n    output_dir = os.path.join(EVALS_DIR, \"results\")\n    try:\n        folders: list[OutputFolder] = []\n        for folder_name in os.listdir(output_dir):\n            folder_path = os.path.join(output_dir, folder_name)\n            if os.path.isdir(folder_path) and not folder_name.startswith(\".\"):\n                # Get modification time\n                modified_time = os.path.getmtime(folder_path)\n                folders.append(\n                    OutputFolder(\n                        name=folder_name, path=folder_path, modified_time=modified_time\n                    )\n                )\n\n        # Sort by modified time, most recent first\n        return sorted(folders, key=lambda x: x.modified_time, reverse=True)\n    except Exception as e:\n        raise HTTPException(\n            status_code=500, detail=f\"Error reading output folders: {str(e)}\"\n        )\n","sourceCodeStart":487,"sourceCodeEnd":508,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/routes/evals.py#L487-L508","documentation":"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.","triggerScenarios":"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.","commonSituations":"Fresh clone without the backend/evals directory; cleanup job deleting folders mid-scan; wrong backend working directory.","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."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# backend-side: ensure the directory exists before the endpoint is called\nimport os\nfrom config.config import EVALS_DIR\nos.makedirs(EVALS_DIR, exist_ok=True)","typeGuard":null,"tryCatchPattern":"const res = await fetch('/eval_output_folders');\nconst folders = res.ok ? await res.json() : []; // degrade to empty list","preventionTips":["Create the evals root during backend startup.","Retry once on 500 — TOCTOU races with cleanup jobs are transient."],"tags":["http-500","filesystem","evals","fastapi"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}