{"record":{"id":"eb3ed3e5d29cdd02","repo":"tailscale/tailscale","slug":"unsupported-json-patch-operation-q","errorCode":null,"errorMessage":"unsupported JSON patch operation: %q","messagePattern":"unsupported JSON patch operation: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kube/kubeclient/client.go","lineNumber":298,"sourceCode":"\treturn c.kubeAPIRequest(ctx, \"PUT\", c.resourceURL(s.Name, TypeSecrets, \"\"), s, nil)\n}\n\n// JSONPatch is a JSON patch operation.\n// It currently (2024-11-15) only supports \"add\", \"remove\" and \"replace\" operations.\n//\n// https://tools.ietf.org/html/rfc6902\ntype JSONPatch struct {\n\tOp    string `json:\"op\"`\n\tPath  string `json:\"path\"`\n\tValue any    `json:\"value,omitempty\"`\n}\n\n// JSONPatchResource updates a resource in the Kubernetes API using a JSON patch.\n// It currently (2024-11-15) only supports \"add\", \"remove\" and \"replace\" operations.\nfunc (c *client) JSONPatchResource(ctx context.Context, name, typ string, patches []JSONPatch) error {\n\tfor _, p := range patches {\n\t\tif p.Op != \"remove\" && p.Op != \"add\" && p.Op != \"replace\" {\n\t\t\treturn fmt.Errorf(\"unsupported JSON patch operation: %q\", p.Op)\n\t\t}\n\t}\n\treturn c.kubeAPIRequest(ctx, \"PATCH\", c.resourceURL(name, typ, \"\"), patches, nil, setHeader(\"Content-Type\", \"application/json-patch+json\"))\n}\n\n// StrategicMergePatchSecret updates a secret in the Kubernetes API using a\n// strategic merge patch.\n// If a fieldManager is provided, it will be used to track the patch.\nfunc (c *client) StrategicMergePatchSecret(ctx context.Context, name string, s *kubeapi.Secret, fieldManager string) error {\n\tsurl := c.resourceURL(name, TypeSecrets, \"\")\n\tif fieldManager != \"\" {\n\t\tuv := url.Values{\n\t\t\t\"fieldManager\": {fieldManager},\n\t\t}\n\t\tsurl += \"?\" + uv.Encode()\n\t}\n\ts.Namespace = c.ns\n\ts.Name = name","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/tailscale/tailscale/blob/6e0912f97994f927632b34ae9e63b53d6516a6ac/kube/kubeclient/client.go#L280-L316","documentation":"Raised in JSONPatchResource before any request is sent when a patch entry's Op is not add, remove, or replace. The kube client validates patches locally to avoid sending RFC 6902 operations it has not tested; the caller's patch list is at fault.","triggerScenarios":"Thrown at kube/kubeclient/client.go:298 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The JSON patch contains an unsupported operation; use only supported patch operations (add, remove, replace, etc.) in the request."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6e0912f97994f927632b34ae9e63b53d6516a6ac","analyzedAt":"2026-08-18T08:17:25.280Z","contentChangedAt":"2026-08-18T08:17:25.280Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}