{"record":{"id":"cfff289ac6c02c68","repo":"srbhr/Resume-Matcher","slug":"failed-to-delete-application-please-try-again","errorCode":null,"errorMessage":"Failed to delete application. Please try again.","messagePattern":"Failed to delete application\\. Please try again\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"apps/backend/app/routers/applications.py","lineNumber":159,"sourceCode":"        updates[\"status\"] = request.status.value\n    try:\n        updated = await db.update_application(application_id, updates)\n    except Exception as e:\n        logger.error(\"Failed to update application %s: %s\", application_id, e)\n        raise HTTPException(status_code=500, detail=\"Failed to update application. Please try again.\")\n    if updated is None:\n        raise HTTPException(status_code=404, detail=\"Application not found\")\n    return ApplicationResponse(**updated)\n\n\n@router.delete(\"/{application_id}\", response_model=ApplicationActionResponse)\nasync def delete_application(application_id: str) -> ApplicationActionResponse:\n    \"\"\"Delete a card.\"\"\"\n    try:\n        deleted = await db.delete_application(application_id)\n    except Exception as e:\n        logger.error(\"Failed to delete application %s: %s\", application_id, e)\n        raise HTTPException(status_code=500, detail=\"Failed to delete application. Please try again.\")\n    if not deleted:\n        raise HTTPException(status_code=404, detail=\"Application not found\")\n    return ApplicationActionResponse(message=\"Application deleted\", affected=1)\n\n\n@router.post(\"/bulk-delete\", response_model=ApplicationActionResponse)\nasync def bulk_delete_applications(request: BulkDelete) -> ApplicationActionResponse:\n    \"\"\"Delete many cards.\"\"\"\n    try:\n        deleted = await db.bulk_delete_applications(request.application_ids)\n    except Exception as e:\n        logger.error(\"Failed to bulk-delete applications: %s\", e)\n        raise HTTPException(status_code=500, detail=\"Failed to delete applications. Please try again.\")\n    return ApplicationActionResponse(message=f\"Deleted {deleted} application(s)\", affected=deleted)\n\n\nasync def _extract_company_role(job_description: str) -> dict[str, str | None]:\n    \"\"\"Best-effort company/role extraction for the manual-add path.","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/backend/app/routers/applications.py#L141-L177","documentation":"This 500 HTTPException is raised by the delete_application route when the underlying db.delete_application() call throws any exception. It is a generic wrapper that hides the database error from the client while logging the real cause server-side. It means the delete operation failed at the persistence layer, not that the application was missing (that is the 404 path).","triggerScenarios":"DELETE /applications/{id} where db.delete_application raises: MongoDB connection failure/timeout, collection unavailable, serialization error in the motor/pymongo driver, or any other unhandled exception inside the db layer.","commonSituations":"Database is down or restarting, connection pool exhausted, network partition between backend and DB, DB credentials rotated, or a bug in db.delete_application raising on unexpected document shape.","solutions":["Check backend logs for the 'Failed to delete application %s' line to see the underlying exception","Verify the database (MongoDB) is reachable and credentials are valid","Retry the delete; transient DB issues resolve after reconnection","Fix the root-cause exception in the db layer's delete_application once identified"],"exampleFix":"// before\ndeleted = await db.delete_application(application_id)\n// after\ntry:\n    deleted = await db.delete_application(application_id)\nexcept Exception as e:\n    logger.error(\"Failed to delete application %s: %s\", application_id, e)\n    raise HTTPException(status_code=500, detail=\"Failed to delete application. Please try again.\")","handlingStrategy":"try-catch","validationCode":"const exists = await api.getApplication(id).then(() => true).catch(() => false)\nif (!exists) console.warn(`application ${id} missing; skipping delete`)","typeGuard":null,"tryCatchPattern":"try {\n  await api.deleteApplication(id)\n} catch (e) {\n  if (e.response?.status === 404) return // already gone\n  if (e.response?.status === 500) {\n    logger.error('delete failed server-side', e)\n    showToast('Delete failed, please retry')\n  }\n}","preventionTips":["Check backend logs immediately after a 500 to find the real DB error","Monitor database connectivity/health from the backend","Treat 404 as success in idempotent delete flows","Retry transient failures with backoff"],"tags":["http-500","database","delete"],"backgroundTag":"database-operation-failed","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}