Ray's Knowledge Base
Unlock

An unquoted null in a YAML list is a null, not the string "null"

PitfallVerified 27 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A YAML front matter with a tag list such as tags: [query, null, regex] (or - null on its own line) fails to load where strings are expected. rkb refused it with:

frontmatter: invalid type: unit value, expected a string

Cause#

YAML reads a bare null (also ~ and an empty value) as the null value, not text. Other bare words change type too, such as true, false, and numbers.

Fix#

Quote the word: - "null", - "true", - "1.0".

Evidence#

  • 2026-09-27: rkb add with the tag - null failed as above; - "null" was accepted (lesson 54489520b7).

Also found by searching

  • frontmatter: invalid type: unit value, expected a string
  • a tag named null in my YAML list breaks loading the file
  • how do I put the literal word null or true in a YAML list of strings
  • serde_yaml tags list bare null parsed as None not string, quote it
  • YAML tags list [query, null, regex] loads null instead of the word
  • how do I write the word null or true as a string in a YAML list?
  • yaml bare null ~ true false 1.0 get converted to non-string types, norway problem in tags