Fix runner-label indentation in custom jobs by Copilot · Pull Request #70840 · github/gh-aw · GitHub
Skip to content

Fix runner-label indentation in custom jobs - #70840

Merged
pelikhan merged 5 commits into
mainfrom
copilot/fix-extra-indentation-in-job-labels
Oct 21, 2026
Merged

pelikhan merged 5 commits into
mainfrom
copilot/fix-extra-indentation-in-job-labels

Conversation

Copilot AI commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Custom jobs with multiple runs-on labels compiled with extra indentation after the first label, causing incorrect runner matching and indefinitely queued jobs.

  • Serialization: Marshal each field with its value before applying job-level indentation, preserving sibling labels in custom and safe-output jobs.
  • Regression coverage: Assert exact indentation and round-trip preservation of runner labels.

The reported example now compiles as:

runs-on:
  - self-hosted
  - linux
  - x64
  - something

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix extra indentation in compiled workflow for custom jobs Fix runner-label indentation in custom jobs Oct 21, 2026
Copilot AI requested a review from dsyme October 21, 2026 09:21
Align replacement mappings by their first key to avoid panics when runner selections change shape. Cover scalar, sequence, mapping, expression, quoted, folded, anchor, and alias forms across parsing, emission, and edits.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review October 21, 2026 11:03
Copilot AI max review requested due to automatic review settings October 21, 2026 11:03
@pelikhan

Copy link
Copy Markdown
Collaborator

@pelikhan

Copy link
Copy Markdown
Collaborator

/review

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · sonnet50 · 14.2 AIC · ⌖ 15.4 AIC · ◇ 6.71 AIC · ⊞ 12.7K · ◷

🧪 Test quality analysis by Test Quality Sentinel

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The shared source-preserving YAML alignment changes warrant maintainer review beyond the targeted runner-label fix.

No open issues 🎉

What changed in this PR

Fixes runner-label serialization in gh-aw so custom and safe-output jobs preserve correct runner matching, addressing #70811.

Changes:

  • Serializes fields with their values before applying job indentation.
  • Standardizes source-node alignment during YAML emission.
  • Adds indentation and round-trip regression coverage and documents runner-value preservation.
File Description
pkg/​workflow/​safe_jobs_test.go Corrects expected label indentation.
pkg/​workflow/​compiler_jobs_custom_fields_test.go Tests runner forms and compiled label preservation.
pkg/​workflow/​compiler_custom_job_execution.go Fixes field serialization and indentation.
pkg/​workflow/​aw/​document_test.go Tests runner values across document round trips and edits.
pkg/​workflow/​aw/​doc.go Documents preserved runner forms.
pkg/​workflow/​actions/​workflow_test.go Tests runner emission, edits, and aliases.
pkg/​workflow/​actions/​source_sequence.go Uses shared node-column alignment.
pkg/​workflow/​actions/​source_merge.go Centralizes alignment for source-preserving merges.
pkg/​workflow/​actions/​doc.go Documents native runner values and expressions.

Review effort: Max

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict

No actionable blocking issues found in the changed lines. The serialization change correctly marshals the field name together with its value before applying indentation, and the added round-trip coverage exercises scalar, sequence, mapping, expression, anchor, and alias forms. Static review only; tests were not executed.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · 1.43 AIC · ⌖ 0.547 AIC · ⊞ 1.6K
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — approving. Root cause properly fixed with strong regression coverage.

📋 Analysis

Root cause fix, not a patch

The original bug was that formatIndentedYAMLField marshaled the runs-on value standalone, then prepended a fixed 6-space indent to every line including the first sequence item — misaligning subsequent items. The fix wraps the value in map[string]any{fieldName: value} before marshaling, letting go-yaml's own indentation engine produce consistent indentation across all lines. This addresses the actual cause rather than special-casing the symptom, and the same helper is shared by runs-on, strategy, concurrency, container, services, and environment, so all callers benefit.

Regression coverage

  • TestCompileCustomJobRunnerLabels reproduces the exact bug report (#70811) end-to-end through CompileWorkflow and asserts both the raw lock-file bytes and the round-tripped YAML structure.
  • TestBuildCustomJobsRunsOnForms gained single label array and object with labels cases that pin exact expected indentation.
  • safe_jobs_test.go assertions were corrected to the now-proper indentation (previously encoded the buggy output).
  • The actions/aw packages added exhaustive RunsOn round-trip tests (scalars, quoted/expression forms, flow/block arrays, group/labels maps, anchors and aliases) covering parse → emit → reparse stability for every shape, which is excellent /tdd-style boundary coverage for a YAML-AST-sensitive area.

Verification

Ran the full affected test surface locally (pkg/workflow, pkg/workflow/actions, pkg/workflow/aw) plus go build ./... — all pass.

Minor observation (non-blocking)

The sourceNodeColumn extraction in source_merge.go/source_sequence.go is a clean, welcome dedup of previously duplicated column-finding logic — no action needed.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 58 AIC · ⌖ 15.2 AIC · ⊞ 10.2K
Comment /matt to run again

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · haiku45 · 5.16 AIC · ⌖ 10.2 AIC · ◇ 2.45 AIC · ⊞ 9.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #70840

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Commit pushed: f29324a

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two test matrices provide exhaustive pairwise transitions without corresponding production branches; retain representation parsing and a small set of boundary edits.

net: -26 lines possible.

Generated by ✂️ Ponytail Reviewer for #70840 · codex · gpt56 · 10.4 AIC · ⌖ 5.34 AIC · ⊞ 14.8K
Comment /ponytail to run again

Comment thread pkg/workflow/actions/workflow_test.go Outdated
Comment thread pkg/workflow/aw/document_test.go Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (289 new lines under pkg/) but does not link an Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/70840-serialize-job-fields-as-keyed-yaml-and-align-by-key-column.md. Review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR on your branch. It was generated from the PR diff and records two decisions: (a) formatIndentedYAMLField now marshals the field with its key and indents only continuation lines; (b) a shared sourceNodeColumn helper now sets the re-indentation column for all source-AST merges.
  2. Complete or correct the sections: add context the diff does not show, refine the reasoning, and confirm the alternatives you actually considered.
  3. Commit the finalized ADR to docs/adr/ on your branch.
  4. Reference the ADR in this PR body, for example:

    ADR: ADR-70840: Serialize Job Fields as Keyed YAML and Align Merged Nodes by Key Column

Once the PR body links an ADR, this gate re-runs and checks that the implementation matches the decision.

❓ Why ADRs Matter

ADRs are a searchable, permanent record of why the codebase looks the way it does. Future contributors, including your future self, will thank you.

📋 Michael Nygard ADR Format Reference

An ADR is complete only if it has these four sections:

  • Context: What is the problem? What forces are at play?
  • Decision: What did you decide, and why?
  • Alternatives Considered: What else could have been done?
  • Consequences: What are the trade-offs, positive and negative?

ADRs are stored in docs/adr/ and numbered by PR number.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · opus55 · 25.2 AIC · ⌖ 40.4 AIC · ⊞ 1.9K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: comment

No actionable blocking issues found in the changed lines. The serialization fix correctly marshals the field together with its value before applying job indentation, and the source-column helper consistently handles nested mappings and sequences. The added round-trip and compiled-YAML coverage exercises scalar, sequence, mapping, expression, anchor, and alias forms. Static review only; tests were not run per review constraints.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · 5.01 AIC · ⌖ 0.532 AIC · ⊞ 1.6K
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd (confirmed via pr-triage: change_type=bug_fix). This is a clean, well-tested root-cause fix — approving.

📋 Key Themes & Highlights

Root cause analysis

The bug (#70811) was that formatIndentedYAMLField marshaled the runs-on value alone (e.g. []any{...}) and then manually prefixed fieldName + ":" plus a fixed 6-space indent per line. Because the YAML encoder did not know the value was nested under a parent key, its own internal sequence-indentation math did not account for that extra nesting level, producing doubled dashes after the first list item. The fix wraps the value in map[string]any{fieldName: value} before marshaling, so goccy/go-yaml computes indentation for the actual nested structure, then re-indents only the continuation lines by a fixed 4 spaces. I reproduced both old and new behavior directly (yaml.MarshalWithOptions with/without wrapping) and confirmed the new approach yields correctly aligned sibling labels.

Verified correctness

  • Ran go test ./pkg/workflow/... — all RunsOn/CustomJobRunnerLabels tests pass, including the new 27 round-trip cases across scalars, flow/block arrays, group/labels mappings, expressions, and YAML anchors/aliases.
  • Confirmed the error path for unmarshalable values (chan int) still fails correctly after wrapping.
  • gofmt -l and go vet ./pkg/workflow/... are clean on the changed files.
  • The shared sourceNodeColumn() helper in source_merge.go nicely deduplicates three near-identical column-calculation blocks that previously existed separately in source_merge.go and source_sequence.go — good refactor hygiene alongside the bug fix.

Positive highlights

  • ✅ Root cause fixed (serialization context), not just the symptom (manual line-prefixing)
  • ✅ Extensive regression coverage at both the actions.Workflow and aw.Document levels, including edit-and-reparse stability checks
  • ✅ safe_jobs_test.go expectations updated consistently, since extractCustomJobRunsOn/formatIndentedYAMLField are shared between custom jobs and safe-output jobs
  • ✅ Doc comments (doc.go files) updated to describe the preserved runner forms

No actionable issues found in the changed lines; this PR is ready to merge.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 87.7 AIC · ⌖ 15 AIC · ⊞ 10.2K
Comment /matt to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Keep every runs-on representation round trip and alias regression while testing eight representative edits per AST, including the block-list-to-mapping panic and each AW execution field kind.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan merged commit b8d79b6 into main Oct 21, 2026
35 of 36 checks passed
@pelikhan
pelikhan deleted the copilot/fix-extra-indentation-in-job-labels branch October 21, 2026 12:09
Copilot AI requested a review from gh-aw-bot October 21, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] AW 0.92.0 compiles custom jobs with extra indents with runner labels

5 participants