{
  "id": "python/sqlalchemy-orm-exc-unmapped-class-error",
  "signature": "sqlalchemy.orm.exc.UnmappedClassError: Class 'app.models.User' is not mapped",
  "signature_zh": "类 'app.models.User' 未映射",
  "regex": "sqlalchemy\\.orm\\.exc\\.UnmappedClassError:\\ Class\\ 'app\\.models\\.User'\\ is\\ not\\ mapped",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "The ORM class has not been properly registered with a Base or declarative base, or the module containing the class was not imported before session usage.",
  "root_cause_type": "generic",
  "root_cause_zh": "ORM 类未正确注册到 Base 或声明性基类，或者包含该类的模块在会话使用前未被导入。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding decorators to the class",
      "why_fails": "",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Re-importing the class later",
      "why_fails": "",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Correctly inherit from declarative base",
      "success_rate": 0.95,
      "how": "Ensure the class inherits from Base = declarative_base() and import it before any session operations.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Create all tables to trigger mapping",
      "success_rate": 0.9,
      "how": "Call Base.metadata.create_all(engine) after defining all models to ensure mapping is established.",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}