TL;DR: GitHub Actions accepts several invalid YAML productions, making it difficult (read: impossible) to parse some real-world action and workflow definitions with a properly conforming YAML parser.

This is related to zizmor#1116, which has been bugging me for a year and a half.

Last April, a user reported that zizmor was rejecting a workflow containing a step that looks like this:.

Apart from the use of a multi-line flow-style string for the json: key, nothing particularly stands out about this step.

According to recent reports, except: it isn't valid YAML! YAML indicates this about flow-style nodes that are nested inside of a block-style parent collection (read: map or array):. (Related: Industry News: Block Sparse Matrices for Smaller and Fa...)

Flow nodes must be indented by at least one more space than the parent block collection. Note that flow nodes may begin on a following line. (Related: Understanding BigBird's Block Sparse Attention...)

That means the correct syntax is instead:.

The difference is barely visible:.

YAML is a major and complicated spec, so it didn't even occur to me that this was invalid. Instead, I opened tree-sitter-yaml#36 to "fix" it. I've now opened tree-sitter-yaml#51 to revert that misbegotten fix.

According to recent reports, on GitHub's side, I'm not sure if they have a clean path towards spec conformance here. Much of the code behind Actions is proprietary, but it seems likely that the underlying parser on their end is YamlDotNet.

Actions appears to use YamlDotNet 5.3.0, which was released in 2018. However, even upgrading to the newest version (18.1.0 as of writing) wouldn't fix this particular bug, since it's still present on that version (note the !isSingleQuoted guard).

My best guess is that a 2020 patch (YamlDotNet#467) only fixed the double-quoted form because YAML's official test suite only tests rule 8.2.3 with a double-quoted string, despite it applying to both forms.

β†’ Read original article