{
  "id": "python/starlette-background-task-exception-swallowed",
  "signature": "Exception in background task ignored: RuntimeError('task failed')",
  "signature_zh": "后台任务中的异常被忽略：RuntimeError('task failed')",
  "regex": "Exception\\ in\\ background\\ task\\ ignored:\\ RuntimeError\\('task\\ failed'\\)",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A BackgroundTask raised an exception after the response was sent; Starlette logs it but the client already received 200.",
  "root_cause_type": "generic",
  "root_cause_zh": "BackgroundTask 在响应发送后抛出异常；Starlette 记录了它，但客户端已经收到 200。",
  "versions": [
    {
      "version": "0.30+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Hides failures from monitoring; no retries or alerts.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Background tasks run after the response; the route already returned.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "import logging\nlogger = logging.getLogger(__name__)\ndef task():\n    try:\n        do_work()\n    except Exception:\n        logger.exception('background failed')\n        raise",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from celery import Celery\ncelery = Celery('app')\ncelery.send_task('do_work')",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-12-04",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}