{
  "id": "python/sqlalchemy-invalid-relationship-argument",
  "signature": "sqlalchemy.exc.ArgumentError: relationship 'User.posts' expects a class or a mapper argument (received: <class 'str'>)",
  "signature_zh": "sqlalchemy.exc.ArgumentError: relationship 'User.posts' 期望一个类或映射器参数（收到：<class 'str'>）",
  "regex": "sqlalchemy\\.exc\\.ArgumentError:\\ relationship\\ 'User\\.posts'\\ expects\\ a\\ class\\ or\\ a\\ mapper\\ argument\\ \\(received:\\ <class\\ 'str'>\\)",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Passing a string to relationship() without proper string resolution context, e.g., using a non-existent class name.",
  "root_cause_type": "generic",
  "root_cause_zh": "向 relationship() 传递了字符串，但未在正确的字符串解析上下文中，例如使用了不存在的类名。",
  "versions": [
    {
      "version": "1.4.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2.0.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If the class is not yet defined, it will raise NameError.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "NameError occurs because the class is not in scope.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Ensure the class is defined before the relationship: class Post(Base): ...; class User(Base): posts = relationship(Post)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Use string with full module path if using declarative: posts = relationship('myapp.models.Post')",
      "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-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}