microsoft/aspire · error · JsonException
JSON Patch operation
Error message
JSON Patch operation '{operation}' is not supported. What it means
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.
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'.
Example fix
// before
[ { "op": "move", "from": "/a/b", "path": "/a/c" } ]
// after
[ { "op": "remove", "path": "/a/b" }, { "op": "add", "path": "/a/c", "value": <movedValue> } ] Defensive patterns
Strategy: validation
Validate before calling
var allowedOps = new HashSet<string> { "add", "remove", "replace" };
bool AllOpsSupported(JsonNode patch) =>
patch.AsArray().All(op => op["op"]!.GetValue<string>() is string s && allowedOps.Contains(s)); Try / catch
try { patch.Apply(target); }
catch (JsonException ex) when (ex.Message.Contains("is not supported"))
{
logger.LogError(ex, "Unsupported JSON Patch op: {Message}", ex.Message);
// rewrite move/copy/test ops or fail the update
} Prevention
- 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.
When it happens
Trigger: Applying a patch document containing { "op": "move" }, { "op": "copy" }, { "op": "test" }, or a misspelled op such as 'update' through the DCP resource update path.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- A JSON Patch operation must contain string 'op' and 'path'…
- JSON Patch operation
- Service resources do not consume any services
- Service resources do not produce any services
- A JSON Patch path can only traverse objects and arrays.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/3f9947b24ebdc45c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/Dcp/JsonPatch.cs:183
throw new JsonException($"JSON Pointer segment '{segment}' ends with an incomplete escape.");
}
result.Append(segment[index] switch
{
'0' => '~',
'1' => '/',
_ => throw new JsonException($"JSON Pointer segment '{segment}' contains an invalid escape."),
});
}
return result.ToString();
}
private static JsonNode? ApplyOperation(JsonNode? current, string operation, string[] segments, bool hasValue, JsonNode? value)
{
if (operation is not ("add" or "remove" or "replace"))
{
throw new JsonException($"JSON Patch operation '{operation}' is not supported.");
}
if (operation is not "remove" && !hasValue)
{
throw new JsonException($"JSON Patch operation '{operation}' requires a 'value' property.");
}
if (segments.Length == 0)
{
return operation switch
{
"remove" => null,
_ => value?.DeepClone(),
};
}
var parent = GetParent(current, segments);
var finalSegment = segments[^1];View on GitHub (pinned to 25830f84bd)