# pydantic_core._pydantic_core.ValidationError: 1 validation error for Node
children.0.parent
  Recursion error - cyclic reference detected [type=recursion_loop]

- **ID:** `python/pydantic-recursion-loop-detected`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The input data contains a cyclic reference (e.g. an object referencing itself), which Pydantic detects while validating a recursive model.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   def strip_parent(node):
    node.pop('parent', None)
    for c in node.get('children', []):
        strip_parent(c)
    return node
Node.model_validate(strip_parent(data))
   ```
2. **** (80% success)
   ```
   from pydantic import BaseModel

class Node(BaseModel):
    name: str
    children: list['Node'] = []

Node.model_rebuild()  # avoid modeling parent back-references
   ```

## Dead Ends

- **** — The cycle is in the data itself, not stack depth. It will still be detected and may crash the interpreter. (85% fail)
- **** — Loses the schema definition and breaks legitimate nested validation for non-cyclic inputs. (70% fail)
