UnprocessableEntity (422)
KubernetesERRORNotableAPI InteractionHIGH confidence

The request is invalid

Production Risk

This error prevents new or updated configurations from being deployed, but it does not affect running workloads. It is a user-facing configuration error.

What this means

The Kubernetes API server understood the request, but the instructions in the request body are semantically incorrect. For example, trying to create a resource with a field that has an invalid value.

Why it happens
  1. 1A field in the manifest has an invalid value (e.g., an unknown `restartPolicy`)
  2. 2Trying to update an immutable field (e.g., the name of a pod)
  3. 3The manifest is syntactically correct YAML but violates a Kubernetes schema rule
How to reproduce

Running `kubectl apply` or `kubectl create` fails with an 'Unprocessable Entity' error.

trigger — this will error
trigger — this will error
kubectl apply -f my-pod.yaml

expected output

The Pod "my-pod" is invalid: spec.restartPolicy: Unsupported value: "Sometimes": supported values: "Always", "OnFailure", "Never"

Fix 1

Read the error message carefully

WHEN The API server returns a 422 error

Read the error message carefully
kubectl apply -f my-pod.yaml

Why this works

The error message from the API server is usually very specific, pointing to the exact field in the manifest that is incorrect and often suggesting the valid values.

Fix 2

Use `--validate` for local validation

WHEN You want to check a manifest for errors before sending it to the API server

Use `--validate` for local validation
kubectl apply -f my-pod.yaml --validate=true

Why this works

The validate flag performs client-side validation against the Kubernetes API schema, which can catch many formatting and value errors before submission.

What not to do

Attempt to force the update

Unlike a conflict (409), a 422 error is a hard validation failure. The API server will never accept the resource until the semantic error in the manifest is corrected.

Sources
Official documentation ↗

k8s.io/apimachinery/pkg/api/errors/errors.go

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Kubernetes errors