#1066·yaml

ambiguous parse error messages

Author: aep-sunlifeCreated Feb 10, 2025Updated Feb 10, 2025

Hi,

When a user provides a YAML file with invalid syntax, then I expect go-yaml to present very clear, direct error messages about the nature of the syntax error. However, in practice, I am seeing vague, misleading messages.

Image

Error from go-yaml:

bash
$ snack
2025/02/10 10:19:37 yaml: line 2: did not find expected key
  • The line number indicated is confusing. The actual problem occurs with some keys indented at a single space column, not a random column after the document opening marker.
  • The error says "did not find expected key" but fails to indicate which keys were expected
  • The error omits the fact that a single space character was encountered where keys were expected