{
  "id": "dotnet/aspnetcore-json-cycle",
  "signature": "System.Text.Json.JsonException: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64.",
  "signature_zh": "System.Text.Json.JsonException: 检测到可能的对象循环。这可能是由于循环引用或对象深度超过最大允许深度 64。",
  "regex": "System\\.Text\\.Json\\.JsonException.*possible object cycle was detected",
  "domain": "dotnet",
  "category": "serialization_error",
  "subcategory": null,
  "root_cause": "JsonSerializer encounters a circular reference in the object graph (e.g., navigation properties referencing each other) or the nesting depth exceeds the default limit.",
  "root_cause_type": "generic",
  "root_cause_zh": "JsonSerializer 在对象图中遇到循环引用（例如导航属性相互引用）或嵌套深度超过默认限制。",
  "versions": [
    {
      "version": "dotnet 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "dotnet 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "System.Text.Json 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "System.Text.Json 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Does not break the cycle; serializer will still fail with stack overflow or infinite loop.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "May hide needed data; can break client-side functionality if important relationships are omitted.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Newtonsoft.Json also has a default reference loop handling that throws; needs explicit configuration.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Configure System.Text.Json to handle reference loops using ReferenceHandler.Preserve. Example in Program.cs.",
      "success_rate": 0.9,
      "how": "Configure System.Text.Json to handle reference loops using ReferenceHandler.Preserve. Example in Program.cs.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use DTOs or view models that flatten the object graph, avoiding circular references.",
      "success_rate": 0.85,
      "how": "Use DTOs or view models that flatten the object graph, avoiding circular references.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set ReferenceHandler.IgnoreCycles to ignore navigation properties that cause cycles.",
      "success_rate": 0.8,
      "how": "Set ReferenceHandler.IgnoreCycles to ignore navigation properties that cause cycles.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Configure System.Text.Json to handle reference loops using ReferenceHandler.Preserve. Example in Program.cs.",
    "Use DTOs or view models that flatten the object graph, avoiding circular references.",
    "Set ReferenceHandler.IgnoreCycles to ignore navigation properties that cause cycles."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/preserve-references",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-07-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}