{
  "id": "python/fastapi-sqlalchemy-async-session-not-bound",
  "signature": "sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here.",
  "signature_zh": "sqlalchemy.exc.MissingGreenlet: greenlet_spawn 未被调用；此处无法调用 await_only()。",
  "regex": "sqlalchemy\\.exc\\.MissingGreenlet:\\ greenlet_spawn\\ has\\ not\\ been\\ called;\\ can't\\ call\\ await_only\\(\\)\\ here\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Lazy-loading a relationship on an AsyncSession outside an awaited greenlet context, e.g. in template rendering or sync code.",
  "root_cause_type": "generic",
  "root_cause_zh": "在异步会话之外的 greenlet 上下文中对 AsyncSession 的关系进行延迟加载，例如在模板渲染或同步代码中。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Dynamic still requires I/O; the greenlet error persists.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Blocks the event loop and breaks FastAPI async handling.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.94,
      "how": "from sqlalchemy.orm import selectinload\nresult = await session.execute(select(User).options(selectinload(User.posts)))",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "await session.refresh(user, ['posts'])",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-11-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}