{"record":{"id":"3f9947b24ebdc45c","repo":"microsoft/aspire","slug":"json-patch-operation-operation-is-not-supported","errorCode":null,"errorMessage":"JSON Patch operation '{operation}' is not supported.","messagePattern":"JSON Patch operation '(.+?)' is not supported\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Dcp/JsonPatch.cs","lineNumber":183,"sourceCode":"                throw new JsonException($\"JSON Pointer segment '{segment}' ends with an incomplete escape.\");\n            }\n\n            result.Append(segment[index] switch\n            {\n                '0' => '~',\n                '1' => '/',\n                _ => throw new JsonException($\"JSON Pointer segment '{segment}' contains an invalid escape.\"),\n            });\n        }\n\n        return result.ToString();\n    }\n\n    private static JsonNode? ApplyOperation(JsonNode? current, string operation, string[] segments, bool hasValue, JsonNode? value)\n    {\n        if (operation is not (\"add\" or \"remove\" or \"replace\"))\n        {\n            throw new JsonException($\"JSON Patch operation '{operation}' is not supported.\");\n        }\n\n        if (operation is not \"remove\" && !hasValue)\n        {\n            throw new JsonException($\"JSON Patch operation '{operation}' requires a 'value' property.\");\n        }\n\n        if (segments.Length == 0)\n        {\n            return operation switch\n            {\n                \"remove\" => null,\n                _ => value?.DeepClone(),\n            };\n        }\n\n        var parent = GetParent(current, segments);\n        var finalSegment = segments[^1];","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Dcp/JsonPatch.cs#L165-L201","documentation":"JsonPatch.ApplyOperation supports only the RFC 6902 operations 'add', 'remove', and 'replace'. Any other 'op' value — including valid RFC 6902 ops like 'move', 'copy', and 'test', which this minimal implementation deliberately does not support — throws a JsonException.","triggerScenarios":"Applying a patch document containing { \"op\": \"move\" }, { \"op\": \"copy\" }, { \"op\": \"test\" }, or a misspelled op such as 'update' through the DCP resource update path.","commonSituations":"Patches generated by generic JSON Patch libraries that emit the full RFC 6902 op set; hand-written patches using 'move'/'copy' for convenience; drift between a producer updated for RFC completeness and Aspire's minimal applier.","solutions":["Rewrite 'move' as a 'remove' + 'add' pair of operations.","Rewrite 'copy' as an explicit 'add' carrying the copied value.","Remove 'test' operations or implement pre-checks in the patch producer.","Fix misspelled op names to one of 'add', 'remove', 'replace'."],"exampleFix":"// before\n[ { \"op\": \"move\", \"from\": \"/a/b\", \"path\": \"/a/c\" } ]\n// after\n[ { \"op\": \"remove\", \"path\": \"/a/b\" }, { \"op\": \"add\", \"path\": \"/a/c\", \"value\": <movedValue> } ]","handlingStrategy":"validation","validationCode":"var allowedOps = new HashSet<string> { \"add\", \"remove\", \"replace\" };\nbool AllOpsSupported(JsonNode patch) =>\n    patch.AsArray().All(op => op[\"op\"]!.GetValue<string>() is string s && allowedOps.Contains(s));","typeGuard":null,"tryCatchPattern":"try { patch.Apply(target); }\ncatch (JsonException ex) when (ex.Message.Contains(\"is not supported\"))\n{\n    logger.LogError(ex, \"Unsupported JSON Patch op: {Message}\", ex.Message);\n    // rewrite move/copy/test ops or fail the update\n}","preventionTips":["Restrict generated patches to 'add', 'remove', 'replace'.","Expand 'move' into remove+add and 'copy' into add before sending.","Pin the patch-producing library/config to the supported op subset."],"tags":["json-patch","rfc6902","unsupported-operation","dcp"],"backgroundTag":"unsupported-operation","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}