DEV Community

Cover image for GitHub Actions Accepts Invalid YAML. actionlint and yamllint Don't Catch It
Alan West
Alan West

Posted on Originally published at blog.authon.dev

GitHub Actions Accepts Invalid YAML. actionlint and yamllint Don't Catch It

GitHub Actions will run a workflow file that isn't valid YAML. The bug comes down to one missing space in a multi-line single-quoted string, and it's in a real, public repo's workflow where GitHub still runs that step without an error. I ran actionlint 1.7.12 and yamllint 1.38.0 on it and neither one complained. zizmor refuses to parse it, and for over a year zizmor has been the one taking the blame.

William Woodruff, who maintains zizmor, wrote it up on 2026-11-22 in a TIL called "GitHub Actions accepts invalid YAML". I read the post, the zizmor issue behind it and the runner source, then ran the examples through the linters most of us have in pre-commit. At the end there's the lint setup I'd use to match what GitHub actually enforces.

The one-space YAML bug GitHub Actions runs anyway

The step comes from jfrog/setup-jfrog-cli, reported in zizmor#1116 in August 2025. Reduced to its shape:

- name: Create NPM Remote Repository JSON
  uses: jsdaniell/create-json@v1.2.3
  with:
    name: "npm-remote-template.json"
    json: '{
      "key": "npm-remote",
      "rclass": "remote",
      "packageType": "npm",
      "url": "https://registry.npmjs.org"
    }'
Enter fullscreen mode Exit fullscreen mode

Look at the closing }'. It sits at the same column as json:. YAML 1.2.2 ยง8.2.3 says:

Flow nodes must be indented by at least one more space than the parent block collection.

So this is invalid. The valid version moves }' one column to the right:

-    }'
+     }'
Enter fullscreen mode Exit fullscreen mode

GitHub runs the invalid version without a warning. Woodruff's minimal reproducer in the issue is three lines:

foo:
  bar: '{
  }'
Enter fullscreen mode Exit fullscreen mode

Which YAML parser accepts it

Every tool in your pipeline ships its own YAML parser, and they disagree at the edges:

Parser Used by Verdict on the }' case
YamlDotNet 5.3.0 (YamlDotNet.Signed) GitHub's runner, per Sdk.csproj Accepts
PyYAML yamllint, lots of Python scripts Accepts ({'foo': {'bar': '{ }'}})
go-yaml v4 (v4.0.0-rc.3) actionlint 1.7.12 Accepts (no syntax error in my run)
tree-sitter-yaml zizmor, tree-sitter based editors Rejects
The spec nobody's CI Rejects

Most of the Actions backend is closed source, so "GitHub uses YamlDotNet" is Woodruff's inference from the open-source runner. It's a reasonable one: the runner pins YamlDotNet 5.3.0, a 2018 release. Upgrading wouldn't help either. Per the post, the scanner in 18.1.0 still skips the indentation check for single-quoted scalars. The line in Scanner.cs is:

if (hasLeadingBlanks && !isSingleQuoted && indent >= cursor.LineOffset)
Enter fullscreen mode Exit fullscreen mode

Woodruff's theory for how that happened: a 2020 patch fixed a batch of yaml-test-suite error cases, and the official test suite only covers ยง8.2.3 with a double-quoted string. So the library passes the conformance case and still gets the single-quoted form wrong.

What bothers me most is that Woodruff had already "fixed" tree-sitter-yaml to accept this form in PR #36. GitHub accepted it, so it seemed valid. After reading the spec, Woodruff opened PR #51 to revert it. The lenient parser had already started bending the strict one, which is how a parser bug becomes a de facto standard.

GitHub runs the step, your scanner skips the file

GitHub runs the step with the JSON you meant. The breakage shows up in every other tool that reads that file. A strict parser fails on it, so a security scanner can't scan it at all. A hook built on a different library may build a different tree than the one GitHub executes. In the zizmor case the file was unscannable and users filed it as a zizmor bug. The issue has been open since August 2025 and picked up duplicates in December 2025, March 2026 and September 2026.

Will GitHub fix it? Woodruff: "I'm not sure if they have a clean path towards spec conformance here." Rejecting this input now would break existing workflows that run fine today. On the Lobsters thread, one commenter hopes GitHub doesn't add a "quirks mode" and another replies that it's "almost certainly what they'll do, if they do anything." My bet is GitHub never changes it and third-party tools slowly grow a "GitHub-compatible" flag.

Duplicate keys in GitHub Actions: stricter than plain YAML

If GitHub is this lax about indentation, you might assume it also lets duplicate keys through with last-one-wins. It doesn't. The runner's TemplateReader.cs tracks keys like this:

var keys = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
// ...
if (!keys.Add(nextKey.Value))
{
    m_context.Error(nextKey, TemplateStrings.ValueAlreadyDefined(nextKey.Value));
    SkipValue();
    continue;
}
Enter fullscreen mode Exit fullscreen mode

A duplicate is an error, and the comparison is case-insensitive, so env and ENV collide. One exception: keys containing ${{ }} expressions hit continue before that check, so they're never compared at read time.

Here your local tooling is wrong in the other direction. I put a matrix with version_name and VERSION_NAME through yamllint 1.38.0 with key-duplicates on, and it passed. GitHub would reject it. actionlint models GitHub's rules and catches it:

test.yaml:8:9: key "VERSION_NAME" is duplicated in "matrix" section. previously defined at line:7,col:9. note that this key is case insensitive [syntax-check]
Enter fullscreen mode Exit fullscreen mode

GitHub's dialect is looser than the spec in one place and stricter in another, and yamllint only checks generic YAML. You need a tool that models GitHub's rules to catch the difference.

How to lint GitHub Actions workflows: actionlint, yamllint, zizmor

I'd run all three, because each catches things the others miss.

actionlint knows GitHub's workflow schema, case-insensitive keys and expression types, and runs shellcheck on run: blocks. Since v1.7.10 it also reports YAML merge keys (<<) as errors, because GitHub doesn't support them. Install with brew install actionlint or go install github.com/rhysd/actionlint/cmd/actionlint@latest, or skip installing:

docker run --rm -v $(pwd):/repo --workdir /repo rhysd/actionlint:latest -color
Enter fullscreen mode Exit fullscreen mode

yamllint covers formatting and structure, but it needs a config that stays quiet about GitHub-isms. GitHub uses YAML 1.2, so on: is a string key, but yamllint's truthy rule treats it as a YAML 1.1 boolean by default. Turn off key checking rather than sprinkling disable comments, and drop the --- requirement, which GitHub doesn't need:

# .yamllint
extends: default
rules:
  key-duplicates:
    forbid-duplicated-merge-keys: true
  truthy:
    check-keys: false
  line-length: disable
  document-start: disable
Enter fullscreen mode Exit fullscreen mode

zizmor is for security. It's also the only tool here whose parser rejects the }' case, which makes it a decent canary for files that only GitHub can read.

Wire the first two into pre-commit so problems fail on your laptop and not in a PR:

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/rhysd/actionlint
    rev: v1.7.12
    hooks:
      - id: actionlint
  - repo: https://github.com/adrienverge/yamllint.git
    rev: v1.38.0
    hooks:
      - id: yamllint
        args: [--strict, -c=.yamllint]
Enter fullscreen mode Exit fullscreen mode

The actionlint hook builds with Go. If you don't have a Go toolchain, use actionlint-docker or actionlint-system instead. Run actionlint in CI too, because someone on your team will commit with --no-verify.

None of this catches the one-space bug, though. With that exact config, yamllint passed the jfrog step and actionlint reported nothing for it. If you have JSON blobs in with: inputs, stop writing them as multi-line quoted scalars. Use a | block scalar and the indentation rule stops being a trap:

    json: |
      {"key": "npm-remote", "rclass": "remote", "packageType": "npm", "url": "https://registry.npmjs.org"}
Enter fullscreen mode Exit fullscreen mode

A quick way to find candidates is to search your workflows for a line that ends in '{ or '[, then check where the closing quote lands.

Run actionlint on your repo

On a repo that has never seen it, actionlint usually turns up something: a shellcheck warning, an undefined needs, a matrix key that only differs by case.

What did it find in yours that GitHub had been running all along? And if you think GitHub should break the invalid workflows and force everyone onto the spec, make that case in the comments. I'd like to hear it argued seriously.

Sources

Top comments (0)