Skip to content

Parenthesize agentic-workflow fork guards to emit valid YAML - #130338

Merged
jeffhandley merged 1 commit into
dotnet:mainfrom
jeffhandley:jeffhandley/fix-fork-guards
Jul 8, 2026
Merged

jeffhandley merged 1 commit into
dotnet:mainfrom
jeffhandley:jeffhandley/fix-fork-guards

Conversation

@jeffhandley

Copy link
Copy Markdown
Member

Summary

Several agentic workflows guard against running in forks with a workflow-level if: fork guard. When the guard is a single-term expression, gh aw compile applies it to the generated pre_activation job and emits it inline as if: !github.event.repository.fork. A leading ! is a YAML tag indicator, so the compiled .lock.yml is invalid YAML and GitHub rejects the workflow (could not determine a constructor for the tag '!github.event.repository.fork').

Wrapping the expression in parentheses makes both the source frontmatter and the emitted pre_activation condition start with ( instead of !, producing valid YAML with identical evaluation. The ${{ }} wrapper is redundant (gh aw compile strips it) and is dropped, matching breaking-change-doc.md, which already omits it.

Changes

  • ci-failure-fix.md, ci-failure-scan.md, ci-failure-scan-feedback.md, and code-review.md: fork guard is now if: (!github.event.repository.fork), with .lock.yml files recompiled via gh aw compile --schedule-seed dotnet/runtime.
  • shared/pat_pool.README.md: new "Fork guards must be wrapped in parentheses" entry under Known Issues, since the bug only surfaces on the pre_activation job created by the PAT-pool on.permissions: {} workaround.

ci-failure-fix, ci-failure-scan, and ci-failure-scan-feedback were emitting invalid lock files. code-review was valid at runtime (its pull_request trigger produces a compound, already-parenthesized guard) but is updated for consistency.

Note

This pull request was prepared by GitHub Copilot CLI on behalf of @jeffhandley.

The workflow-level `if:` fork guard is applied to the generated
`pre_activation` job. A single-term `!github.event.repository.fork`
guard was emitted inline as `if: !github.event.repository.fork`, which
is invalid YAML because a leading `!` is a tag indicator.

- ci-failure-fix, ci-failure-scan, ci-failure-scan-feedback, code-review:
  change the guard to `if: (!github.event.repository.fork)` and recompile
- shared/pat_pool.README.md: document the fork-guard gotcha under Known Issues

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 8, 2026 08:23
@jeffhandley
jeffhandley requested a review from a team as a code owner July 8, 2026 08:23
@github-actions github-actions Bot added the area-skills Agent Skills label Jul 8, 2026

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.

Pull request overview

This PR updates several agentic workflow frontmatter fork guards so the compiled *.lock.yml workflows remain valid YAML when gh aw compile inlines the workflow-level if: onto the generated pre_activation job.

Changes:

  • Updated workflow-level fork guards in affected *.md workflows to if: (!github.event.repository.fork) (avoids YAML tag parsing of leading ! after compilation).
  • Recompiled the corresponding *.lock.yml files so pre_activation.if no longer begins with !github.event.repository.fork.
  • Documented the issue and the required workaround in shared/pat_pool.README.md.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.github/workflows/shared/pat_pool.README.md Documents the pre_activation + fork-guard/YAML-tag pitfall and the parentheses workaround.
.github/workflows/code-review.md Updates workflow-level fork guard to a parenthesized expression.
.github/workflows/code-review.lock.yml Recompiled output reflecting the updated fork-guard shape in generated jobs.
.github/workflows/ci-failure-scan.md Updates workflow-level fork guard to a parenthesized expression.
.github/workflows/ci-failure-scan.lock.yml Recompiled output; pre_activation.if is now YAML-safe.
.github/workflows/ci-failure-scan-feedback.md Updates workflow-level fork guard to a parenthesized expression.
.github/workflows/ci-failure-scan-feedback.lock.yml Recompiled output; pre_activation.if is now YAML-safe.
.github/workflows/ci-failure-fix.md Updates workflow-level fork guard to a parenthesized expression.
.github/workflows/ci-failure-fix.lock.yml Recompiled output; pre_activation.if is now YAML-safe.

@jeffhandley
jeffhandley enabled auto-merge (squash) July 8, 2026 08:28
@jeffhandley
jeffhandley merged commit b444cf8 into dotnet:main Jul 8, 2026
29 checks passed
@jeffhandley
jeffhandley deleted the jeffhandley/fix-fork-guards branch July 8, 2026 09:18
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 10, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
## Summary

Several agentic workflows guard against running in forks with a
workflow-level `if:` fork guard. When the guard is a single-term
expression, `gh aw compile` applies it to the generated `pre_activation`
job and emits it inline as `if: !github.event.repository.fork`. A
leading `!` is a YAML tag indicator, so the compiled `.lock.yml` is
invalid YAML and GitHub rejects the workflow (`could not determine a
constructor for the tag '!github.event.repository.fork'`).

Wrapping the expression in parentheses makes both the source frontmatter
and the emitted `pre_activation` condition start with `(` instead of
`!`, producing valid YAML with identical evaluation. The `${{ }}`
wrapper is redundant (`gh aw compile` strips it) and is dropped,
matching `breaking-change-doc.md`, which already omits it.

## Changes

- `ci-failure-fix.md`, `ci-failure-scan.md`,
`ci-failure-scan-feedback.md`, and `code-review.md`: fork guard is now
`if: (!github.event.repository.fork)`, with `.lock.yml` files recompiled
via `gh aw compile --schedule-seed dotnet/runtime`.
- `shared/pat_pool.README.md`: new "Fork guards must be wrapped in
parentheses" entry under Known Issues, since the bug only surfaces on
the `pre_activation` job created by the PAT-pool `on.permissions: {}`
workaround.

`ci-failure-fix`, `ci-failure-scan`, and `ci-failure-scan-feedback` were
emitting invalid lock files. `code-review` was valid at runtime (its
`pull_request` trigger produces a compound, already-parenthesized guard)
but is updated for consistency.

> [!NOTE]
> This pull request was prepared by GitHub Copilot CLI on behalf of
@jeffhandley.

Co-authored-by: Copilot <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-skills Agent Skills

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants