{"record":{"id":"46f0a9d1a6bff3cd","repo":"lfnovo/open-notebook","slug":"failed-to-delete-episode-profile","errorCode":null,"errorMessage":"Failed to delete episode profile","messagePattern":"Failed to delete episode profile","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/episode_profiles.py","lineNumber":235,"sourceCode":"    try:\n        profile = await EpisodeProfile.get(profile_id)\n\n        if not profile:\n            raise HTTPException(\n                status_code=404, detail=f\"Episode profile '{profile_id}' not found\"\n            )\n\n        await profile.delete()\n\n        return {\"message\": \"Episode profile deleted successfully\"}\n\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Failed to delete episode profile: {e}\")\n        raise HTTPException(\n            status_code=500, detail=\"Failed to delete episode profile\"\n        )\n\n\n@router.post(\n    \"/episode-profiles/{profile_id}/duplicate\", response_model=EpisodeProfileResponse\n)\nasync def duplicate_episode_profile(profile_id: str):\n    \"\"\"Duplicate an episode profile\"\"\"\n    try:\n        original = await EpisodeProfile.get(profile_id)\n\n        if not original:\n            raise HTTPException(\n                status_code=404, detail=f\"Episode profile '{profile_id}' not found\"\n            )\n\n        duplicate = EpisodeProfile(","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/episode_profiles.py#L217-L253","documentation":"Generic 500 raised when deleting an episode profile fails unexpectedly during profile.delete() or response construction.","triggerScenarios":"DB outage or timeout during the delete; record referenced by other data causing a driver-level error; permissions failure on the SurrealDB table.","commonSituations":"SurrealDB restarting mid-request, concurrent write conflicts on the same record, restricted DB user lacking delete permission.","solutions":["Check logs for the exact traceback on 'Failed to delete episode profile'","Verify DB connectivity and permissions","Retry the delete once the DB is stable","If references block deletion, remove dependents first or adjust schema"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    resp = await client.delete(f\"/api/episode-profiles/{profile_id}\")\n    if resp.status_code < 500 or resp.status_code == 404 or attempt:\n        break\n    await asyncio.sleep(1)","preventionTips":["Confirm SurrealDB permissions allow deletes for the API user","Check logs for the real exception before retrying blindly","Avoid concurrent deletes of the same record from multiple clients"],"tags":["http-500","internal-error","episode-profile","delete"],"backgroundTag":"internal-server-error","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}