{
  "id": "python/fastapi-runtimeerror-coroutine-object-is-not-callable",
  "signature": "RuntimeError: coroutine object is not callable",
  "signature_zh": "RuntimeError: 协程对象不可调用",
  "regex": "RuntimeError:\\ coroutine\\ object\\ is\\ not\\ callable",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Trying to call a coroutine as a function without using await, or assigning a coroutine to a variable and then calling it.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试将协程作为函数调用而未使用 await，或者将协程赋值给变量后调用。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Calling an async function without await inside a sync function.",
      "why_fails": "Sync functions cannot use await; calling an async function returns a coroutine object, not the result.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Storing a coroutine in a variable and then using () on it.",
      "why_fails": "The variable holds a coroutine object; calling it again tries to call the coroutine, which is not allowed.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use await when calling async functions.",
      "success_rate": 0.95,
      "how": "async def get_data():\n    return await fetch_data()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Run the coroutine in an event loop if outside async context.",
      "success_rate": 0.85,
      "how": "import asyncio\nresult = asyncio.run(async_function())",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}