title: Error while applying JSON Patch to Kubernetes Custom Resource
body: <p>I have an instance of a Kubernetes <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/" rel="noreferrer">Custom Resource</a> that I want to patch via the Kubernetes API using a JSON patch.</p>
  
  <p>This is my PATCH request:</p>
  
  <pre><code>PATCH /apis/example.com/v1alpha1/namespaces/default/mycrd/test HTTP/1.1
  Accept: application/json
  Content-Type: application/json-patch+json
  [other headers omitted for brevity...]
  
  [
    {"op": "replace", "path": "/status/foo", value: "bar"}
  ]
  </code></pre>
  
  <p>I'm fairly certain that my request body is a valid <a href="http://jsonpatch.com/" rel="noreferrer">JSON patch</a>, and I've previously already successfully updated core (non-CRD) API resources using similar API calls. The CRD has a <code>openAPIV3Schema</code> defined that explicitly allows <code>.status.foo</code> to exist and to be of type <code>string</code>.</p>
  
  <p>The request above is declined by the Kubernetes API server with the following response:</p>
  
  <pre><code>HTTP/1.1 422 Unprocessable Entity
  Conent-Type: application/json
  [other headers omitted for brevity...]
  
  {
    "kind": "Status",
    "apiVersion": "v1",
    "metadata": {},
    "status": "Failure",
    "message": "the server rejected our request due to an error in our request",
    "reason": "Invalid",
    "details": {},
    "code": 422
  }
  </code></pre>
  
  <p>According to the <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/#common-features" rel="noreferrer">CRD documentation</a>, CRDs should support <code>PATCH</code> request with the <code>application/json-patch+json</code> content type. But for some reason, the request appears to be invalid without Kubernetes bothering to tell me <em>why</em>. The API server pod did not have any relevant messages in its log stream, either.</p>
  
  <p>The same error also occurs when using <code>kubectl patch</code> on the command line:</p>
  
  <pre><code>$ kubectl patch mycrd.example.com test --type=json -p '[{"op": "replace", "path": "/status/foo", "value": "bar"}]'   
  The  "" is invalid
  </code></pre>
  
  <p><strong>What are possible reasons for this error to occur? What options to I have for further debugging?</strong></p>