From dd93cd69415793f105f3c3001796c30f1554dd13 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Mar 2026 11:19:13 +0000 Subject: [PATCH] ci: fix PR number resolution with artifact fallback github.event.workflow_run.pull_requests[0].number can be empty when GitHub cannot resolve the PR association (e.g., head and base branch share the same name). This caused the comment step to fail on PR #1405. Use event context when available, fall back to artifact pr_number file. All downstream steps reference steps.meta.outputs.pr_number. https://claude.ai/code/session_01Lr3k5y8UYcH26a8hndo8ek --- .../workflows/verify_data_integrity_comment.yml | 16 +++++++++++++--- .../visualize_stopping_patterns_comment.yml | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/verify_data_integrity_comment.yml b/.github/workflows/verify_data_integrity_comment.yml index 5c5e8868..f78c4d60 100644 --- a/.github/workflows/verify_data_integrity_comment.yml +++ b/.github/workflows/verify_data_integrity_comment.yml @@ -27,7 +27,17 @@ jobs: - name: Read metadata id: meta run: | - echo "pr_number=${{ github.event.workflow_run.pull_requests[0].number }}" >> "$GITHUB_OUTPUT" + PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}" + if [ -z "$PR_NUMBER" ] && [ -s /tmp/validation-artifacts/pr_number ]; then + PR_NUMBER=$(cat /tmp/validation-artifacts/pr_number) + echo "::warning::pull_requests context empty, using artifact fallback" + fi + if [ -z "$PR_NUMBER" ]; then + echo "::error::Could not determine PR number" + exit 1 + fi + echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" + if [ -s /tmp/validation-artifacts/result ]; then echo "result=$(cat /tmp/validation-artifacts/result)" >> "$GITHUB_OUTPUT" else @@ -39,7 +49,7 @@ jobs: uses: peter-evans/find-comment@v3 id: find_comment with: - issue-number: ${{ github.event.workflow_run.pull_requests[0].number }} + issue-number: ${{ steps.meta.outputs.pr_number }} comment-author: "github-actions[bot]" body-includes: "" @@ -47,7 +57,7 @@ jobs: if: steps.meta.outputs.result == 'failure' uses: peter-evans/create-or-update-comment@v4 with: - issue-number: ${{ github.event.workflow_run.pull_requests[0].number }} + issue-number: ${{ steps.meta.outputs.pr_number }} comment-id: ${{ steps.find_comment.outputs.comment-id }} body-path: /tmp/validation-artifacts/validation_report.md edit-mode: replace diff --git a/.github/workflows/visualize_stopping_patterns_comment.yml b/.github/workflows/visualize_stopping_patterns_comment.yml index 2fe0bea3..e4e99550 100644 --- a/.github/workflows/visualize_stopping_patterns_comment.yml +++ b/.github/workflows/visualize_stopping_patterns_comment.yml @@ -29,7 +29,17 @@ jobs: - name: Read metadata id: meta run: | - echo "pr_number=${{ github.event.workflow_run.pull_requests[0].number }}" >> "$GITHUB_OUTPUT" + PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}" + if [ -z "$PR_NUMBER" ] && [ -s /tmp/visualize-artifacts/pr_number ]; then + PR_NUMBER=$(cat /tmp/visualize-artifacts/pr_number) + echo "::warning::pull_requests context empty, using artifact fallback" + fi + if [ -z "$PR_NUMBER" ]; then + echo "::error::Could not determine PR number" + exit 1 + fi + echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" + if [ -s /tmp/visualize-artifacts/has_changes ]; then echo "has_changes=$(cat /tmp/visualize-artifacts/has_changes)" >> "$GITHUB_OUTPUT" else @@ -41,7 +51,7 @@ jobs: uses: peter-evans/find-comment@v3 id: find_comment with: - issue-number: ${{ github.event.workflow_run.pull_requests[0].number }} + issue-number: ${{ steps.meta.outputs.pr_number }} comment-author: "github-actions[bot]" body-includes: "" @@ -49,7 +59,7 @@ jobs: if: steps.meta.outputs.has_changes == 'true' uses: peter-evans/create-or-update-comment@v4 with: - issue-number: ${{ github.event.workflow_run.pull_requests[0].number }} + issue-number: ${{ steps.meta.outputs.pr_number }} comment-id: ${{ steps.find_comment.outputs.comment-id }} body-path: /tmp/visualize-artifacts/visualization_comment.md edit-mode: replace