kubectl: metadata.resourceVersion: Invalid value: 0x0
The 0x0 error means an update carried no resourceVersion. Switch to apply or patch, or read the live object first, and keep versions out of Git.

Introduction & Quick Summary
kubectl rejects an update before the API server touches etcd:
The Deployment "web" is invalid: metadata.resourceVersion: Invalid value:
0x0: must be specified for an update0x0 is Go's zero value for a string printed as hex — in practice, an empty metadata.resourceVersion. Kubernetes carries a resource version on every object and requires it on a full replacement (PUT) so two writers cannot overwrite each other blindly. A manifest taken from Git has no resource version, so any path that turns it into a PUT fails with this message.
Quick answer, in order of preference:
kubectl apply -f deploy.yaml # PATCH, no resourceVersion needed
kubectl patch deployment web --type=merge -p '{"spec":{"replicas":3}}'
kubectl apply --server-side -f deploy.yaml # server-side apply, no resourceVersion neededUse kubectl replace only with an object that carries the live resource version:
kubectl replace -f deploy.yaml # fails: no resourceVersion
kubectl get deploy web -o yaml | kubectl replace -f - # succeeds: live objectWho hits it: kubectl replace in a script, a controller or operator calling the Update API with a struct it built from scratch, Terraform's Kubernetes provider when a resource is recreated from imported state, and migration jobs that rewrite manifests with yq and then replace.
Core Mechanics, Signatures & Reproducible Setup
The API server's write verbs differ in what they require:
| Verb | HTTP | Requires resourceVersion | Conflict detection |
|---|---|---|---|
| create | POST | no; ignored if present | AlreadyExists |
| update | PUT | yes | 409 if it does not match live |
| patch | PATCH | no, unless an optimistic-lock precondition is sent | 409 on that precondition |
| apply (client-side) | PATCH | no | merge semantics per field |
| apply (server-side) | PATCH with field manager | no | 409 ApplyFailedConflict on foreign fields |
| delete | DELETE | no, optional Preconditions | 404 if gone |
A minimal reproduction, using a namespace you can throw away:
kubectl create ns rvtest
kubectl -n rvtest create deployment web --image=nginx --replicas=1
kubectl -n rvtest get deploy web -o yaml > web.yaml
kubectl -n rvtest replace -f web.yaml # works: file came from the cluster
kubectl -n rvtest get deploy web -o yaml \
| grep -v 'resourceVersion\|uid:\|creationTimestamp\|generation' > bare.yaml
kubectl -n rvtest replace -f bare.yaml # 0x0 errorThe server has no version to compare against, and an unconditional PUT would silently discard a concurrent change — exactly the bug resource versions exist to prevent.
Two related strings appear in the same situations and mean different things:
Operation cannot be fulfilled on deployments.apps "web": the object has been
modified; please apply your changes to the latest version and try againThat is a version that was present but stale (HTTP 409). 0x0 is a version that was absent (HTTP 422). A retry loop fixes the first if it re-reads the object; it never fixes the second.
Key Comparison Table
Choosing the write path for a GitOps or scripted deploy:
| Approach | Holds state in | Idempotent | Needs resourceVersion | Field ownership |
|---|---|---|---|---|
kubectl apply (client-side) | last-applied-configuration annotation | yes | no | last writer wins per key |
kubectl apply --server-side | managedFields | yes | no | per-field manager, conflicts surfaced |
kubectl replace | caller | yes, but destructive | yes | full object replaced |
kubectl patch | caller | yes | no | touched fields only |
kubectl create | caller | no | no | n/a |
| Helm upgrade | release secret | yes | no | three-way merge patch |
What each error is telling you:
| Message | HTTP | Cause | Fix |
|---|---|---|---|
resourceVersion: Invalid value: 0x0 | 422 | PUT without a version | use apply or patch, or read the live object first |
the object has been modified | 409 | PUT with a stale version | re-get, re-apply your change, retry |
ApplyFailedConflict | 409 | two field managers own one field | --force-conflicts with a chosen manager name |
metadata.resourceVersion: Invalid value: "123": must be specified for an update | 422 | quoted or numeric version from a template | pass it as a string from the API |
field is immutable | 422 | a field the API forbids changing | recreate the object |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
1. Replace inside a deploy script
# broken: manifest from the repo has no resourceVersion
kubectl replace -f k8s/deployment.yaml
# fixed: apply is the right verb for declarative files
kubectl apply -f k8s/deployment.yaml
# fixed, if replace is genuinely required
RV=$(kubectl get deploy web -o jsonpath='{.metadata.resourceVersion}')
yq -i ".metadata.resourceVersion = \"$RV\"" k8s/deployment.yaml
kubectl replace -f k8s/deployment.yamlThe environment variable form is what the second half of that snippet relies on; if you keep these commands in a script, review how the shell expands them with the environment variable reference, because a missing RV reproduces the original error with a confusing twist.
2. Generating a manifest by editing kubectl get -o yaml
kubectl get -o yaml includes resourceVersion, uid, generation, creationTimestamp, and status. Feeding that output to replace in a different cluster fails with uid mismatch or a version conflict rather than 0x0, and stripping the wrong subset produces 0x0. Strip deterministically:
kubectl get deploy web -o yaml \
| yq 'del(.metadata.resourceVersion, .metadata.uid, .metadata.generation,
.metadata.creationTimestamp, .metadata.managedFields, .status)' \
> clean.yamlyq 4 requires the quoted expression form above; yq 3 used del(...) without quotes. Compare the two outputs with the YAML formatter before committing, since a YAML indentation change is easier to spot there than in a diff of a 700-line manifest.
3. Server-side apply and its own conflicts
kubectl apply --server-side --field-manager=ci-pipeline -f deploy.yaml
# ApplyFailedConflict: conflict with "kubectl-client-side-apply"
kubectl apply --server-side --field-manager=ci-pipeline --force-conflicts -f deploy.yamlServer-side apply does not need resource versions; it needs a stable manager name. Two pipelines using different names will fight over the same replicas field, and every deploy logs a conflict until one of them owns it. Pick the name once and keep it in the pipeline configuration.
4. Controllers and client-go Update calls
An informer cache holds an object that can be several seconds old. Calling Update on the cached copy sends its resource version, which the server may have already moved past:
// unsafe: object comes from the lister, version may be stale
obj, _ := lister.Deployments(ns).Get(name)
obj.Spec.Replicas = ptr.To(int32(3))
_, err := client.AppsV1().Deployments(ns).Update(ctx, obj, metav1.UpdateOptions{})
// conflict-tolerant: re-read on 409 and retry with backoff
if apierrors.IsConflict(err) {
return ctrl.Result{Requeue: true}, nil
}A struct built with &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "web"}} — no version at all — produces the 0x0 error on the very first call, which is why operators should always start from a read.
5. Terraform and other declarative tools
The Kubernetes provider performs a create-or-update cycle. After an import, or after a failed apply that partially created the object, the provider can attempt an update with empty state fields and surface the same API message. The fix is to refresh state so the provider learns the live resource_version, then apply again:
terraform state rm kubernetes_deployment.web
terraform import kubernetes_deployment.web default/web
terraform planterraform plan should show no changes after the import. If it does, the configuration and the cluster have diverged, and applying would replace the object wholesale.
6. Checking a manifest before it reaches a cluster
kubectl apply --dry-run=server -f deploy.yaml # validates against the live API
kubectl diff -f deploy.yaml # what apply would change--dry-run=server catches schema errors that client mode misses, including invalid field values, and it does so without writing anything. kubectl diff previews what apply would change.
Common Compilation/Runtime Mistakes & Version Gotchas
Committing resourceVersion to Git. The value is cluster-specific and changes on every write. A pipeline that stores it deploys once and then fails every subsequent run with a stale-version conflict, or succeeds against the wrong cluster if the numbers happen to agree.
Retrying 0x0 in a loop. The error is deterministic: the object never gains a version by being retried. Retry loops belong on 409 conflicts, where a fresh read changes the outcome.
Using --force to escape a conflict. kubectl replace --force deletes and recreates the object, which empties it of everything applied by other tools: sidecar injections, autoscaler annotations, and the persistent volume binding of a StatefulSet pod. On a Deployment it causes a short outage; on a StatefulSet it can be unrecoverable by itself.
Version differences. Server-side apply reached GA in 1.22, and managedFields became the source of truth for ownership. Strict field validation became the default in 1.27, so a typo that used to be ignored now returns strict decoding error: unknown field. kubectl 1.32 and later warn when client and server differ by more than one minor, often the first hint that a CI image is older than the cluster.
Watching what actually changed. After a successful apply, confirm the object moved the way you intended with kubectl get -o yaml and a diff against your file rather than trusting the exit code; kubectl diff and the text diff tool both show the delta, and the second one works when the cluster is unreachable.
Reference material: API concepts: resource versions and Server-side apply.
Official references
primary documentationThe Kubernetes documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Kubernetes work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Kubernetes guides
All Kubernetes guidesKubernetes 1.35: kubelet will not start on a cgroup v1 node
A 1.35 kubelet refuses a cgroup v1 host, and the removed pod-infra flag stops custom images. Check the kernel command line before the node pool.
Kubernetes: x509 certificate has expired or is not yet valid
kubeadm control plane certificates last one year. Renew them, restart the static pods, refresh kubeconfigs, and alert before the next expiry.
no matches for kind in version: removed APIs and missing CRDs
kubectl cannot map the manifest to an endpoint. Either the API version was removed or the CRD is absent, and discovery tells you which.
kubectl apply: metadata.annotations: Too long: must have at most 262144 bytes
Client-side apply copies the manifest into an annotation. Use server-side apply, remove the legacy annotation, and resolve field conflicts once.
More in Kubernetes
All Kubernetes guidesThe guides filed next to this one in Kubernetes, in library order.