World map

 

BM: Baca dalam Bahasa Melayu

World D0: Start Here

YAML part 2: nesting and traps

You will learn: how spaces put YAML lines inside each other, and how to dodge tabs, lost zeros and sneaky true values.

Checked with Docker Engine 29 on 31 Oct 2026

The problem

bash
docker compose config
failed to parse /home/you/shop/compose.yaml: go-yaml load error in scanner (while scanning for the next token) at L3.C1: found character that cannot start any token
docker compose config fails: found character that cannot start any token, at line 3, column 1.

One invisible tab broke a whole file. That is the real message. In plain words: line 3 starts with a tab, and YAML allows only spaces.

Watch

A tiffin carrier stacks bowls inside one carrier. YAML stacks with spaces. Two more spaces mean “inside the line above”. This is nesting: A box inside a box. In YAML, two more spaces put a line inside the line above..

Change chicken curry to rendang. See where it lives in the box.

tiffin.yaml7 lines

How a computer reads it

  • tiffinmap · 3 keys
    • topricetext
    • middlechicken currytext
    • bottomlist · 2 items
      • item 1eggtext
      • item 2cucumbertext

Predict

The bottom: line and its list move 2 spaces left. Now bottom: lines up with tiffin:. Where does it end up?

Pick one answer.

Try it

Line 3 is one space short. Read the box: the reader’s real words, then plain words. Line it up. On a phone, use “Add a space”.

Put middle back inside the tiffin.

tiffin.yaml5 lines

How a computer reads it

yaml: line 2: did not find expected key

In plain words: Line 3 isn't lined up. Match the keys next to it.

Watch

Most YAML bugs come from a few sneaky traps. Fine, or a trap? Sort them.

Drag a card into a box. Or tap the card, then tap the box.

      Try it

      Look at the box: the reader sees a number, 123456789. The first 0 is gone! Phone numbers are text. Quotes keep the 0.

      Make the phone number text again.

      shop.yaml4 lines

      How a computer reads it

      • nameKedai Kanciltext
      • phone123456789number
      • opentruetrue/false

      Check

      spicy: yes. Kubernetes reads that as true. How do you keep the word yes?

      Pick one answer.

      You did it!

      You can now nest YAML with spaces and dodge its sneaky traps.

      Go deeper (optional)

      Tools use different YAML readers. Older readers (YAML 1.1) turn yes, no, on and off into true or false. Newer ones keep them as words. Quotes are safe everywhere.

      Real rep (optional): in your code editor, turn on “show whitespace”. Tabs and spaces look different then. Open a YAML file and check it.