{
  "id": "dotnet/aspnetcore-json-patch-document-invalid",
  "signature": "Microsoft.AspNetCore.JsonPatch.JsonPatchException: The property at path 'path' could not be updated.",
  "signature_zh": "Microsoft.AspNetCore.JsonPatch.JsonPatchException: 路径 'path' 处的属性无法更新。",
  "regex": "JsonPatchException: The property at path '.*' could not be updated",
  "domain": "dotnet",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A JSON Patch operation (e.g., replace, add, remove) targets a property that does not exist on the target object, or the operation violates model validation rules, often due to incorrect path syntax or missing properties.",
  "root_cause_type": "generic",
  "root_cause_zh": "JSON Patch 操作（如 replace、add、remove）针对目标对象上不存在的属性，或操作违反了模型验证规则，通常是由于路径语法错误或缺少属性。",
  "versions": [
    {
      "version": "6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Adding [FromBody] to the action parameter does not fix the patch document; the issue is with the operation path or target model structure.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changing the HTTP method from PATCH to PUT may bypass the patch logic but breaks RESTful conventions and can cause unintended full replacement of the resource.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Validate the JSON Patch document before applying it: use 'var patchDoc = new JsonPatchDocument<MyModel>(); patchDoc.Operations.Add(new Operation(\"replace\", \"/PropertyName\", null, \"newValue\"));' and check that '/PropertyName' exists via reflection or model metadata.",
      "success_rate": 0.85,
      "how": "Validate the JSON Patch document before applying it: use 'var patchDoc = new JsonPatchDocument<MyModel>(); patchDoc.Operations.Add(new Operation(\"replace\", \"/PropertyName\", null, \"newValue\"));' and check that '/PropertyName' exists via reflection or model metadata.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Apply the patch to a copy of the model and use TryValidateModel to catch validation errors: 'var tempModel = new MyModel(); patchDoc.ApplyTo(tempModel); if (!TryValidateModel(tempModel)) return BadRequest(ModelState);'",
      "success_rate": 0.8,
      "how": "Apply the patch to a copy of the model and use TryValidateModel to catch validation errors: 'var tempModel = new MyModel(); patchDoc.ApplyTo(tempModel); if (!TryValidateModel(tempModel)) return BadRequest(ModelState);'",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Validate the JSON Patch document before applying it: use 'var patchDoc = new JsonPatchDocument<MyModel>(); patchDoc.Operations.Add(new Operation(\"replace\", \"/PropertyName\", null, \"newValue\"));' and check that '/PropertyName' exists via reflection or model metadata.",
    "Apply the patch to a copy of the model and use TryValidateModel to catch validation errors: 'var tempModel = new MyModel(); patchDoc.ApplyTo(tempModel); if (!TryValidateModel(tempModel)) return BadRequest(ModelState);'"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/aspnet/core/web-api/json-patch",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-01-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}