From 7cc1498eea955158b805048f8b6bc12d362e9579 Mon Sep 17 00:00:00 2001 From: "cmeans-claude-dev[bot]" <3223881+cmeans-claude-dev[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 11:27:36 -0500 Subject: [PATCH] fix(workflows): guard pr-labels-ci.yml env against missing workflow_run context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attempting to seed the workflow via workflow_dispatch on main after PR #24 merged failed with: Failed to queue workflow run: Invalid Argument - failed to parse workflow: (Line: 55, Col: 14): An expression was expected, (Line: 111, Col: 14): An expression was expected Lines 55 and 111 are `run: |` in both jobs. The real problem is a few lines earlier: the step-level env: references `github.event.workflow_run.id` and `github.event.workflow_run.head_branch`, which are absent when the workflow is triggered via workflow_dispatch (or a validation push). GitHub evaluates step-level env: expressions at queue time — before the job-level `if:` has a chance to skip the job — so the missing context is fatal even though the logic would skip cleanly. This is also the likely explanation for the push-event startup failures in this workflow's run history: every push GitHub validates has been failing to resolve these env: expressions, which is what prevented the file from being registered in the workflow catalogue and made the workflow_run listener never fire. Fix: add `|| ''` null-coalesce fallbacks to both env: expressions. On workflow_run events (the happy path), the fallback is never exercised — behaviour is unchanged. On workflow_dispatch and push events, the env: assignments cleanly resolve to empty strings, the job-level `if:` fails as designed, and the job skips — producing a successful run that finally registers the file with GitHub. Cascade: cmeans/mcp-clipboard should pick up the same fallbacks. They don't exercise workflow_dispatch today, so the bug is latent there, but the guard is strictly more defensive and preserves the verbatim contract. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/pr-labels-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-labels-ci.yml b/.github/workflows/pr-labels-ci.yml index a8ef5f8..f51f4a1 100644 --- a/.github/workflows/pr-labels-ci.yml +++ b/.github/workflows/pr-labels-ci.yml @@ -50,8 +50,8 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} - RUN_ID: ${{ github.event.workflow_run.id }} - HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} + RUN_ID: ${{ github.event.workflow_run.id || '' }} + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch || '' }} run: | # Look up the associated PR. # The API can 404 after a force-push (orphaned run). @@ -106,8 +106,8 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} - RUN_ID: ${{ github.event.workflow_run.id }} - HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} + RUN_ID: ${{ github.event.workflow_run.id || '' }} + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch || '' }} run: | PR="" API_OUT=$(gh api "repos/$REPO/actions/runs/$RUN_ID/pull_requests" \