{
  "id": "python/pydantic-recursion-loop-model",
  "signature": "pydantic.errors.PydanticUserError: A non-annotated attribute was detected: `children = []`. All model fields require a type annotation; if `children` is not meant to be a field, you may be able to resolve this error by annotating it as a `ClassVar` or updating `model_config['ignored_types']`.",
  "signature_zh": "pydantic.errors.PydanticUserError: 检测到未注解的属性：`children = []`。所有模型字段都需要类型注解；若 `children` 不是字段，可将其注解为 `ClassVar` 或更新 `model_config['ignored_types']`。",
  "regex": "pydantic\\.errors\\.PydanticUserError:\\ A\\ non\\-annotated\\ attribute\\ was\\ detected:\\ `children\\ =\\ \\[\\]`\\.\\ All\\ model\\ fields\\ require\\ a\\ type\\ annotation;\\ if\\ `children`\\ is\\ not\\ meant\\ to\\ be\\ a\\ field,\\ you\\ may\\ be\\ able\\ to\\ resolve\\ this\\ error\\ by\\ annotating\\ it\\ as\\ a\\ `ClassVar`\\ or\\ updating\\ `model_config\\['ignored_types'\\]`\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "A class-level assignment without a type annotation is treated as a field in Pydantic v2, even if it was intended as a constant or helper.",
  "root_cause_type": "generic",
  "root_cause_zh": "Pydantic v2 中，没有类型注解的类级赋值会被当作字段，即使原意为常量或辅助变量。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Setting the attribute inside `__init__` instead of at class level changes semantics and breaks serialization.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Adding `ClassVar` but keeping the mutable default still shares state across instances.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Annotate as ClassVar: `from typing import ClassVar\nchildren: ClassVar[list] = []`",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "Add a type annotation: `children: list[Node] = []` if it really is a field (use `Field(default_factory=list)`).",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}