← Back to Blog

YAML Gotchas: The Norway Problem and 9 Other Surprises

April 7, 2026 3 min read By CodeTidy Team

The YAML Trap: How a Simple Format Can Lead to Frustration

Have you ever spent hours debugging a configuration file, only to realize the issue was a subtle YAML gotcha? We've all been there. YAML, short for YAML Ain't Markup Language, is a human-readable serialization format that's widely used in configuration files, data exchange, and more. However, its simplicity can be deceiving, and even experienced developers can fall into its traps.

Table of Contents

  • The Norway Problem: A False Sense of Security
  • Numbers and Strings: The 1.0 vs "1.0" Conundrum
  • Multiline Strings: The Indentation Dilemma
  • Anchors and Merge Keys: A Recipe for Confusion
  • Sexagesimal: A Subtle but Important Distinction
  • Other YAML Pitfalls to Watch Out For
  • Key Takeaways
  • FAQ

The Norway Problem: A False Sense of Security

# config.yml
country: NO

In YAML, NO is a valid boolean value that evaluates to false. This can lead to unexpected behavior when working with configuration files. For instance, if you're using a library that checks for a boolean value, NO might not behave as expected. We recommend using explicit boolean values (true or false) to avoid this issue.

Numbers and Strings: The 1.0 vs "1.0" Conundrum

# config.yml
version: 1.0

In YAML, 1.0 is a number, while "1.0" is a string. This distinction can lead to issues when working with APIs or libraries that expect a specific data type. For example, a JSON API might reject a numeric value when it expects a string. To avoid this, use quotes for string values, and omit them for numeric values.

Multiline Strings: The Indentation Dilemma

# config.yml
description: |
  This is a
  multiline string
  with inconsistent indentation

YAML's multiline string syntax can be tricky. The | character indicates a literal block scalar, but the indentation of the following lines can affect the output. To avoid issues, use consistent indentation and consider using the > character for folded block scalars.

Anchors and Merge Keys: A Recipe for Confusion

# config.yml
defaults: &defaults
  foo: bar
  baz: qux

config:
  <<: *defaults
  foo: overridden

YAML's anchors and merge keys can be powerful tools, but they can also lead to confusion. When using anchors, make sure to define them clearly, and avoid ambiguous merge keys. We recommend using explicit merge keys to avoid unexpected behavior.

Sexagesimal: A Subtle but Important Distinction

# config.yml
time: 12:30:45

YAML supports sexagesimal notation for time and duration values. However, this can lead to issues when working with libraries that expect a specific format. To avoid this, use the !! syntax to specify the data type explicitly.

Other YAML Pitfalls to Watch Out For

  • YAML's syntax can be sensitive to whitespace and indentation. Make sure to use consistent spacing and indentation throughout your files.
  • YAML supports various data types, including dates and timestamps. Use the !! syntax to specify the data type explicitly.
  • YAML's merge keys can lead to unexpected behavior when used with nested objects. Use explicit merge keys to avoid issues.

Key Takeaways

  • Use explicit boolean values to avoid the Norway problem.
  • Distinguish between numbers and strings using quotes.
  • Use consistent indentation and syntax for multiline strings.
  • Define anchors and merge keys clearly to avoid confusion.
  • Specify data types explicitly using the !! syntax.

Q: What is the Norway problem in YAML?

The Norway problem refers to the fact that NO is a valid boolean value in YAML that evaluates to false. This can lead to unexpected behavior when working with configuration files.

Q: How do I avoid issues with multiline strings in YAML?

Use consistent indentation and consider using the > character for folded block scalars.

Q: What is the difference between 1.0 and "1.0" in YAML?

In YAML, 1.0 is a number, while "1.0" is a string. Use quotes for string values, and omit them for numeric values.

AI agent tools available. The CodeTidy MCP Server gives Claude, Cursor, and other AI agents access to 60+ developer tools. One command: npx @codetidy/mcp