Targeting the Right Pull Request in Notification Policies
Last updated: September 15, 2025
When working with notification policies, you may want to add comments or updates to pull requests. While the run.commit.pull_request_id field is available, it may sometimes pointed to an outdated or closed pull request (for example, when branches are reused).
Recommended Approach
To make your policies more reliable, prefer targeting pull requests by commit hash rather than PR ID. The commit hash is always unique and avoids issues caused by branch reuse or PR churn.
pull_request contains {
"commit": run.commit.hash,
"body": your_comment_body,
} if {
run := input.run_updated.run
# your other conditions
}
Additional Considerations
Filter by run type – Ensure your conditions target only the runs you care about (e.g.,
PROPOSEDvs. drift runs).Avoid stale comments – Add guards to skip runs referencing outdated commit data.
Understand field availability – The
pull_requestobject is only populated when push policies process PR diffs, not for all run types.
By using the commit hash and clear conditions, you ensure your notification policies always post to the correct pull request, even in complex workflows with reused branches or multiple PRs.