YAML · Spring / K8s 4 min read ·

Troubleshooting Spring Boot & K8s YAML: Tabs, Colon Spaces, Booleans & Duplicate Keys

Why does visually aligned YAML fail on startup or silently ignore settings? Diagnose Tab indentation, missing colon spaces, duplicate keys, and implicit type traps.

1. Illegal Tab Indentation & Missing Colon Spaces

YAML forbids Tab characters for indentation and requires a space after mapping colons. Pasting snippets from tickets or chat tools often introduces Tabs or collapses port: 8080 into port:8080, which parsers treat as a plain scalar string.

Broken YAML (Tab indent + missing space after colon)
yaml
server:
	port:8080
  servlet:
    context-path: /api
Clean 2-space indented YAML
yaml
server:
  port: 8080
  servlet:
    context-path: /api

2. Duplicate Keys at the Same Level (Silent Override)

In large application.yml files or Kubernetes manifests, contributors often append a duplicate block near the bottom. Most runtime parsers silently overwrite the earlier block instead of throwing an error, causing mysterious "config ignored" outages.

Duplicate datasource key silently overwrites url
yaml
spring:
  datasource:
    url: jdbc:mysql://db-prod:3306/app
  redis:
    host: 10.0.1.8
  datasource:
    hikari:
      maximum-pool-size: 32

3. YAML 1.1 Implicit Type Traps (Norway Problem & Versions)

In YAML 1.1 parsers (such as SnakeYAML or PyYAML), unquoted yes, no, on, off, and NO coerce to booleans, while unquoted version numbers such as 3.10 parse as float 3.1.

Recommended: quote ambiguous string literals explicitly
yaml
region:
  country: "NO"
  feature-enabled: "yes"
app:
  version: "3.10"
  • Lossless AST formatting: ITGrocery Fmt formats YAML directly on the AST, preserving # comments, quotes, and 64-bit integers.
  • Reveal invisible characters: Toggle Whitespace in the toolbar to spot hidden Tabs and trailing spaces immediately.

Pre-Deploy YAML Checklist

  • Verified zero Tab characters and a space after every mapping colon?
  • Checked syntax diagnostics for duplicate keys at the same indentation level?
  • Quoted ambiguous literals like NO, yes/no, on/off, and version strings like "3.10"?

Validate & Format YAML Without Losing Comments

Auto-fix Tab indents and missing colon spaces, catch duplicate keys, and keep comments intact locally.

Open YAML Tool

Related Local Tools

More Troubleshooting Guides

All Guides →