Skip to content

Compiler strips null at the end of any line in frontmatter steps:, corrupting run: scripts #79303

Done

Description

@bchaintreuil

Summary

With gh-aw v1.2.2, a custom step in the frontmatter whose run: block has a line ending in : null is compiled with that null removed. A JSON document written by a heredoc then becomes invalid. The compiler reports no warning.

Reproduce

.github/workflows/repro-null.md:

---
on:
  workflow_dispatch:
permissions:
  contents: read
engine: copilot
steps:
  - name: Write JSON with null values
    run: |
      cat > /tmp/out.json <<'EOF'
      {
        "a": null,
        "b": null
      }
      EOF
      jq empty /tmp/out.json
---

# Repro

Say hello.

gh aw compile repro-null (v1.2.2): ✓ Compiled 1 workflow: 1 succeeded, 0 warnings.

Actual

.github/workflows/repro-null.lock.yml:

      - name: Write JSON with null values
        run: "cat > /tmp/out.json <<'EOF'\n{\n  \"a\": null,\n  \"b\":\n}\nEOF\njq empty /tmp/out.json"

"a": null, is kept (the line ends with a comma), "b": null loses its value. At run time jq empty fails on the invalid JSON.

Expected

The run: script is copied as written: "b": null stays.

Cause

extractTopLevelYAMLSection marshals the section back to YAML, then calls CleanYAMLNullValues on the text (pkg/workflow/frontmatter_extraction_yaml.go L111-L113). That function applies :\s*null\s*$ to every line (pkg/workflow/yaml.go L105 and L450-L458). It is meant for keys like workflow_dispatch: null, but it cannot tell a mapping value from a line inside a block scalar. Custom steps go through it (pkg/workflow/workflow_builder_steps.go L14). By reading the code (not tested), post-steps, env, services and the other sections extracted the same way are exposed too.

The code is unchanged on v1.3.1 and on main.

Suggested fix

Drop null values on the parsed value before marshalling (or render nil as an empty value in the encoder), instead of a regex on the marshalled text. If the text pass stays, limit it to the on section, where workflow_dispatch: is the intended output, and skip block scalars. A test with the frontmatter above would cover it.

Workaround meanwhile: avoid a line that ends with : null in a run: block, for example build the JSON with jq -n.

Activity

  1. locked and limited conversation to collaborators on Nov 19, 2026
  2. unlocked this conversation on Nov 19, 2026
  3. added
    backlog:compiler-workflows
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ai-inspectedbacklog:compiler-workflows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions