error converting YAML to JSON ☸️ Kubernetes

error converting YAML to JSON: yaml: line 12: did not find expected key

The manifest isn’t valid YAML — usually indentation, a tab character, or an unquoted special character.

Seen on: Kubernetes

Meaning

kubectl parses YAML before talking to the cluster. “did not find expected key”, “mapping values are not allowed in this context” and “found character that cannot start any token” all point at the reported line (or the one before it). Tabs are never allowed for indentation.

Common causes

  • Mixed or inconsistent indentation
  • Tab characters
  • Unquoted values containing ': ' or starting with @, *, {, %
  • Helm template producing broken indentation (missing nindent)

⚡ Quick fix

  1. Check the reported line and the line above
  2. Replace tabs with spaces
  3. Quote strings with special characters
  4. Lint: yamllint file.yaml / helm template | kubectl apply --dry-run=client -f -

Detailed fix by platform

Shell

  1. bash
    yamllint deploy.yaml
    grep -nP '\t' deploy.yaml

How to diagnose

  1. Line — Reported line ±1
  2. Tabs — Any tab characters?
  3. Template — Rendered output valid?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.