{
  "id": "python/sqlalchemy-many-to-many-secondary-undefined",
  "signature": "sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Original exception was: sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column 'association.user_id' could not find table 'users' with which to generate a foreign key to target column 'id'",
  "signature_zh": "sqlalchemy.exc.InvalidRequestError: 一个或多个映射器初始化失败——无法继续初始化其他映射器。原始异常：sqlalchemy.exc.NoReferencedTableError: 与列 'association.user_id' 关联的外键找不到表 'users' 来生成指向目标列 'id' 的外键。",
  "regex": "sqlalchemy\\.exc\\.InvalidRequestError:\\ One\\ or\\ more\\ mappers\\ failed\\ to\\ initialize\\ \\-\\ can't\\ proceed\\ with\\ initialization\\ of\\ other\\ mappers\\.\\ Original\\ exception\\ was:\\ sqlalchemy\\.exc\\.NoReferencedTableError:\\ Foreign\\ key\\ associated\\ with\\ column\\ 'association\\.user_id'\\ could\\ not\\ find\\ table\\ 'users'\\ with\\ which\\ to\\ generate\\ a\\ foreign\\ key\\ to\\ target\\ column\\ 'id'",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "In a many-to-many relationship, the secondary table's foreign keys reference tables that are not yet defined or imported.",
  "root_cause_type": "generic",
  "root_cause_zh": "在多对多关系中，关联表的外键引用了尚未定义或导入的表。",
  "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 referenced table is in another module, simple reordering within one file won't help.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Breaks the relationship.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Ensure all referenced models are imported before configuring mappers: from myapp.models import User, Post, association_table",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Use string table names in ForeignKey: Column('user_id', ForeignKey('users.id')) - and make sure users table is defined.",
      "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": "true",
  "first_seen": "2024-05-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}