{
  "id": "python/fastapi-attribute-error-no-attribute-query",
  "signature": "AttributeError: 'Query' object has no attribute 'default'",
  "signature_zh": "AttributeError: 'Query' 对象没有属性 'default'。",
  "regex": "AttributeError:\\ 'Query'\\ object\\ has\\ no\\ attribute\\ 'default'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Using `Query(default=...)` in a Pydantic v2 / FastAPI version where the parameter was renamed to `default` only in newer releases, or mixing `Query()` with `Annotated` incorrectly.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 Pydantic v2 / FastAPI 版本中使用了已重命名的参数，或错误地将 `Query()` 与 `Annotated` 混用。",
  "versions": [
    {
      "version": "0.95.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "0.100.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Downgrade breaks Pydantic v2 compatibility and other features.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Fragile across versions and breaks OpenAPI generation.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use the modern form: `q: Annotated[str | None, Query(max_length=50)] = None`",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Or the older positional style: `q: str = Query(None, max_length=50)` (no `default=` keyword).",
      "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-01-09",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}