{"record":{"id":"4f5cc5b85be01182","repo":"bytedance/deer-flow","slug":"failed-to-delete-filename-str-e","errorCode":null,"errorMessage":"Failed to delete {filename}: {str(e)}","messagePattern":"Failed to delete (.+?): (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/app/gateway/routers/uploads.py","lineNumber":483,"sourceCode":"\n    return UploadListResponse(**result)\n\n\n@router.delete(\"/{filename}\")\n@require_permission(\"threads\", \"delete\", owner_check=True, require_existing=True)\nasync def delete_uploaded_file(thread_id: ThreadId, filename: str, request: Request) -> dict:\n    \"\"\"Delete a file from a thread's uploads directory.\"\"\"\n    try:\n        return await run_file_io(_delete_uploaded_file_for_thread, thread_id, filename, get_effective_user_id())\n    except FileNotFoundError:\n        raise HTTPException(status_code=404, detail=f\"File not found: {filename}\")\n    except PathTraversalError:\n        raise HTTPException(status_code=400, detail=\"Invalid path\")\n    except ValueError as e:\n        raise HTTPException(status_code=400, detail=str(e))\n    except Exception as e:\n        logger.error(f\"Failed to delete {filename}: {e}\")\n        raise HTTPException(status_code=500, detail=f\"Failed to delete {filename}: {str(e)}\")\n","sourceCodeStart":465,"sourceCodeEnd":484,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/uploads.py#L465-L484","documentation":"HTTP 500 raised by DELETE /threads/{thread_id}/uploads/{filename} for any unexpected exception during deletion (permissions, I/O errors, filesystem corruption). The original exception text is included in the detail and logged as 'Failed to delete <filename>'. Unlike the 404/400 branches, this indicates a server-side environment problem.","triggerScenarios":" OSError removing the file: EACCES (wrong ownership, e.g. root-owned file after a container switch), EBUSY (file locked), EXDEV/io errors from a failing volume.","commonSituations":"Uploads volume permission drift after running the gateway as different users; NFS/FUSE mounts with unreliable unlink; files created by the sandbox process with restrictive modes.","solutions":["Check the gateway log for the 'Failed to delete' error line — the {str(e)} names the exact errno/cause.","Fix ownership/permissions on the thread uploads directory so the gateway user can unlink.","If the volume is flaky (NFS), remount or move uploads to local storage, then retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch 500 on delete; inspect detail for errno; surface to operator — retrying without fixing permissions/disk will fail identically.","preventionTips":["Run the gateway under a stable uid and chown the uploads volume to match.","Prefer local volumes over NFS/FUSE for uploads storage.","Include an unlink permission check in deployment smoke tests."],"tags":["upload","http-500","filesystem","delete"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}