
Fixing YAML Errors That Make No Sense Step by Step
A YAML debugging guide: the error catalog across three parsers, a worked session through five stacked mistakes, silent failures and tools to prevent them.
Tag
93 posts

A YAML debugging guide: the error catalog across three parsers, a worked session through five stacked mistakes, silent failures and tools to prevent them.

JSON needs double quotes, but a Python repr or JavaScript literal uses single quotes. What each parser says, why replacing quotes breaks, and safe fixes.

Fix PCDATA invalid Char value and reference to invalid character number: which characters XML 1.0 forbids, how to strip them from 28 MB in 0.03 s and verify.

Unexpected end of JSON input means the text stopped too soon or was empty. Real messages for every cut point, and how to tell truncated from empty.

Why XML fails with Premature end of data in tag: truncated downloads, cut gzip streams and empty responses, how each message differs, and what to check.

An unexpected token error at position 0 means the text is not JSON: usually an HTML error page, the word undefined or an unparsed object. How to tell which.

Read the not well-formed error in ElementTree, lxml and xmllint on a 28.6 MB file: line and column, what the position means and a method to find the cause.

How to read a JSON parse error: what the position means in Python, Node, PHP and jq, twelve common causes, and a method that finds the bad byte fast.

A tested routine for XML that will not parse: check the bytes, then the encoding, then the characters, then the structure, with an error message dictionary.