Skip to content

[no-ci] Fix race condition in PR metadata check workflow#1874

Merged
leofang merged 3 commits intoNVIDIA:mainfrom
leofang:fix-pr-metadata-check-race
Apr 7, 2026
Merged

[no-ci] Fix race condition in PR metadata check workflow#1874
leofang merged 3 commits intoNVIDIA:mainfrom
leofang:fix-pr-metadata-check-race

Conversation

@leofang
Copy link
Copy Markdown
Member

@leofang leofang commented Apr 7, 2026

Summary

The pr-metadata-check workflow reads assignees, labels, and milestone from github.event.pull_request, which is a snapshot taken at event trigger time. When a PR is opened, the opened event fires before labels/milestone/assignee are fully applied (e.g. by automation or rapid manual edits), causing the check to fail with stale data. Re-running the job doesn't help because it re-uses the same stale event payload.

This PR fixes the race by fetching live PR data via gh api instead of relying on the event payload. The downstream validation logic is unchanged.

What changed

  • Replaced github.event.pull_request.{assignees,labels,milestone} env vars with a single gh api call that fetches current PR state
  • Uses --jq to filter the API response to only the 3 fields needed (assignees, labels, milestone)
  • Added PR_NUMBER, GH_REPO, and GH_TOKEN env vars to support the API call
  • All existing validation logic (module labels, type labels, blocked labels, milestone, assignee) remains identical

Test plan

  • Open a test PR and verify the check passes even if labels/milestone are added a few seconds after creation
  • Verify the check still fails correctly when metadata is genuinely missing
  • Verify bot/draft PRs are still skipped

-- Leo's bot

The workflow reads assignees, labels, and milestone from the event
payload, which is a snapshot taken at trigger time. When a PR is
opened, the `opened` event fires before labels/milestone/assignee
are fully applied, causing the check to fail with stale data.

Fix by fetching live PR data via `gh api` instead of relying on the
event payload. The downstream validation logic is unchanged.
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot bot commented Apr 7, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Address review feedback: use gh's built-in --jq flag to extract only
assignees, labels, and milestone from the API response, avoiding
unnecessary processing of the full PR payload.
@leofang leofang self-assigned this Apr 7, 2026
@leofang leofang requested a review from mdboom April 7, 2026 17:10
@leofang leofang added the CI/CD CI/CD infrastructure label Apr 7, 2026
@leofang leofang added this to the cuda.core v0.7.0 milestone Apr 7, 2026
@leofang leofang marked this pull request as ready for review April 7, 2026 17:10
Address review feedback: use the higher-level `gh pr view` command
with --json and --jq instead of constructing the raw API URL.
@leofang leofang added the bug Something isn't working label Apr 7, 2026
@leofang
Copy link
Copy Markdown
Member Author

leofang commented Apr 7, 2026

As discussed in the meeting, I'll merge this after #1871.

@leofang leofang removed this from the cuda.core v0.7.0 milestone Apr 7, 2026
@leofang leofang changed the title Fix race condition in PR metadata check workflow [no-ci] Fix race condition in PR metadata check workflow Apr 7, 2026
@leofang leofang modified the milestone: cuda.core v0.7.0 Apr 7, 2026
@leofang leofang added P0 High priority - Must do! and removed P0 High priority - Must do! labels Apr 7, 2026
@leofang
Copy link
Copy Markdown
Member Author

leofang commented Apr 7, 2026

As discussed in the meeting, I'll merge this after #1871.

Since we are dropping #1871 in favor of #1878, there is no merge conflict and we can merge this right away.

@leofang leofang closed this Apr 7, 2026
@leofang leofang reopened this Apr 7, 2026
@leofang leofang enabled auto-merge (squash) April 7, 2026 22:41
@leofang
Copy link
Copy Markdown
Member Author

leofang commented Apr 7, 2026

/ok to test f1850e0

@leofang leofang merged commit a40fd94 into NVIDIA:main Apr 7, 2026
24 of 25 checks passed
@leofang leofang deleted the fix-pr-metadata-check-race branch April 7, 2026 22:42
@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Doc Preview CI
Preview removed because the pull request was closed or merged.

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

Labels

bug Something isn't working CI/CD CI/CD infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants