Skip to content

gh aw update: rewritten frontmatter causes subsequent update merge conflicts #74224

Done

Description

@davidRchSenacor

Summary

When the 3-way merge of a workflow's source frontmatter during gh aw update produces conflicts, gh-aw does not report the conflict. It tries to parse the file containing the git conflict markers and fails with a misleading YAML error. The workflow is reported as "could not be updated" with a truncated reason.

The conflict also happens on a normal second update for an unmodified consumer. After a successful update gh-aw rewrites the local frontmatter into a normalized form. The next update then compares that normalized file against the original-format upstream base, so the line changed in the new release (imports: pin) conflicts.

Environment

  • gh-aw version: v0.92.0
  • OS: Windows 11, Git Bash
  • Workflow source: a package with imports: and a source: frontmatter field, installed from a GitHub release
  • Update path: gh aw update --cool-down 0, from release v0.5.3 to v0.5.4

Steps to reproduce

  1. Install a package whose .md workflow stub has this upstream frontmatter (comments, indented list):
    imports:
      - owner/repo/workflows/[email protected]
  2. Run gh aw update to a newer release (v0.5.3). It succeeds, and gh-aw rewrites the local stub: comments dropped, keys sorted, quotes stripped, the imports: list unindented:
    imports:
    - owner/repo/workflows/[email protected]
  3. Publish a new release that only changes the pin to @v0.5.4.
  4. Run gh aw update --cool-down 0 again, without touching the local file.

Actual result

⚠ 8 workflow(s) could not be updated
│ aw-1, aw-2, aw-3, aw-4... │ unable to update source frontmatter: failed to parse frontmatter: failed to parse frontmatter: │
✗ workflow update failed
  no workflows were successfully updated

Debug output (DEBUG='*' gh aw update my-aw --cool-down 0 --verbose):

update_merge  Merge conflicts detected: exit_code=1
frontmatter_editor  Failed to parse frontmatter:
[38:1] invalid header option: "|||||| base (original)"
  38 | ||||||| base (original)
  39 |   - owner/repo/workflows/[email protected]
  40 | =======
  41 |   - owner/repo/workflows/[email protected]

The merge conflicts on the imports: line: the base (original upstream format) and the local file (gh-aw-normalized format) both differ from the new upstream version at that line.

Expected result

  1. A merge conflict is reported as one, naming the workflow file and the conflicting lines, not as a YAML parse error.
  2. Ideally, an unmodified local stub does not conflict at all. Either gh-aw should not normalize the stored stub in a way that diverges from the upstream base, or the 3-way merge should compare normalized forms of all three versions.
  3. The summary table should not truncate the reason (the real cause is only visible with DEBUG='*' --verbose).

Workaround

Before each update, reset every .md stub to the upstream stub of the installed tag (plus the source: line), so that the local file equals the merge base. After that, gh aw update reports Updated and compiled 1 workflow(s) with no conflict markers. The workaround has to be repeated for every release, because each successful update normalizes the stub again.

Related finding

The same error appears when the local .md stub has CRLF line endings (Windows, core.autocrlf=true). Every line then differs from the LF base, so the merge also conflicts everywhere. Adding .github/workflows/*.md text eol=lf to .gitattributes fixes only that part.

See also related issue: #73073

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions