Skip to content

Serialize workflow names and generated run names as YAML scalars #76901

Done

Description

@lpcox

Bug

Workflow names are interpolated into hand-written double-quoted YAML without escaping the value. A valid frontmatter string containing a quotation mark or newline therefore does not reliably round-trip into the generated workflow.

The same issue affects the default run-name derived from the workflow name. Setting an explicit run-name avoids that second emission site but does not correct serialization of name itself.

Reviewed on main at c0a0ba9a241c16d1db76adfc2bd170b03379b681:

Minimal example

Create .github/workflows/quoted-name.md:

---
on: workflow_dispatch
permissions:
  contents: read
name: 'Example "quoted" workflow'
run-name: 'Example run'
---

# Example

Summarize the repository.

Compile with:

gh aw compile quoted-name

The current name emitter constructs this fragment:

name: "Example "quoted" workflow"

That is not a correctly serialized scalar. Removing the explicit run-name exercises the second affected emitter as well.

This report confirms the current source/emission behavior; it does not claim a fresh end-to-end CLI reproduction on the cited revision.

Expected behavior

Compilation should preserve the original name as a single YAML string. Quotes, backslashes, line breaks, and other supported characters should either be encoded correctly or rejected with an explicit, field-specific validation error. String contents must not change the surrounding generated mapping.

Suggested fix

  1. Replace manual "%s" quoting at both sites with the repository's YAML-aware scalar serialization/escaping helper, or introduce one shared helper and use it consistently.
  2. Preserve any intentional, supported display-name expression behavior while keeping string serialization separate from expression validation.
  3. Audit other emissions derived from the same name/title value for the same formatting pattern.
  4. Add compiler regressions for quotation marks, backslashes, LF/CRLF, Unicode, punctuation, and names derived from Markdown headings, both with and without an explicit run-name.
  5. Parse generated YAML in the regressions and assert that the decoded scalar equals the source value and that the surrounding top-level key set is unchanged. Check error behavior and lock-file output when input is rejected.

Both affected fields are included here because they share the same serialization defect and should be corrected together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcompilerworkflows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions