Skip to content

Flux: “dry-run failed: failed to create typed patch object”

GitOpstested on Flux v2.10.0 auf k3s v1.37.2+k3s1

A Kustomization stays at READY False and REVISION shows the old commit. Flux ran a dry run against the API server, one object failed – and therefore nothing was applied.

Symptom

flux reconcile kustomization flux-system --with-source
flux get kustomization notes
NAME 	REVISION          	SUSPENDED	READY	MESSAGE
notes	main@sha1:6a2ee938	False    	False	Deployment/notes/notes dry-run failed: failed to create typed patch object (notes/notes; apps/v1, Kind=Deployment): .spec.replicas: expected numeric (int or float), got string

The MESSAGE column names the object, the field and the expected type.

Diagnosis

The running application is untouched – the dry run protected it.

kubectl -n notes get deploy notes
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
notes   1/1     1            1           4m30s

Causes

replicas: zweiWrong type in the manifest

replicas expects a number. A typo turns it into a string, and the API server rejects the object during the dry run.

Dry-RunFlux checks the whole folder first

Before Flux applies anything, it checks all objects with a dry run against the API server. If one fails, it applies nothing – REVISION still shows the old commit.

Fix

Fix the field in Git (a number instead of a string) and push. With --with-source Flux fetches the new commit and applies it.
sed -i 's/replicas: zwei/replicas: 2/' apps/notes/deployment.yaml
git commit -am "notes: zwei Replicas, diesmal als Zahl"
git push
flux reconcile kustomization notes --with-source
kubectl -n notes get deploy notes
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
notes   2/2     2            2           5m36s

Don't: Fixing the object in the cluster with kubectl edit. Flux overwrites it with the state from Git, and the error stays in the repository.

▶
Break it yourself and find it – free
Flux hands-on, day 2: the first app from Git, drift correction, pruning and a typo in the manifest.
Go to day 2 →

FAQ

Why does flux reconcile on the broken Kustomization hang?

It waits until it is ready, i.e. until the timeout. Faster is to trigger flux-system with --with-source – the broken Kustomization follows by itself.

How do I catch this before pushing?

With kubeconform in CI or a kubectl apply --dry-run=server against a test cluster.

Related error patterns

More