{
  "id": "python/starlette-cors-middleware-error",
  "signature": "TypeError: CORSMiddleware.__init__() got an unexpected keyword argument 'allow_origins'",
  "signature_zh": "类型错误：CORSMiddleware.__init__() 得到了一个意外的关键字参数 'allow_origins'",
  "regex": "TypeError:\\ CORSMiddleware\\.__init__\\(\\)\\ got\\ an\\ unexpected\\ keyword\\ argument\\ 'allow_origins'",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The CORSMiddleware in Starlette uses 'allow_origins' but older versions use 'origins'.",
  "root_cause_type": "generic",
  "root_cause_zh": "Starlette中的CORSMiddleware使用'allow_origins'，但旧版本使用'origins'。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using both 'origins' and 'allow_origins' together.",
      "why_fails": "Only one parameter is accepted; using both causes error.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Upgrading starlette but not updating the code.",
      "why_fails": "Newer versions may have changed the parameter name.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check the Starlette version and use the correct parameter name.",
      "success_rate": 0.9,
      "how": "from starlette.middleware.cors import CORSMiddleware\napp.add_middleware(CORSMiddleware, allow_origins=['*'])  # For newer versions",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use 'origins' parameter for older Starlette versions.",
      "success_rate": 0.85,
      "how": "app.add_middleware(CORSMiddleware, origins=['*'])",
      "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": "2025-09-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}