Skip to content

Auto-nominate for backport a pull request fixing a regression #2092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

apiraino
Copy link
Contributor

@apiraino apiraino commented Jun 30, 2025

From #1184:

We should nominate PRs for backport if any of the following are true:

  1. Description mentions a issue which is labeled as [regression]
  2. Description mentions a issue which is milestoned with the beta version number

This patch implements point (1) and adds a check when a new PR is opened. The new backport.rs handler tries to figure to out if a PR should be nominated for backport.

This handler is enabled by adding a new [backport] config item. The format allows multiple instances of the config so teams can handle backports as they wish.

# "foo" is just to disambiguate multiple instances of this config
[backport.foo]
# The pull request MUST have one of these labels
required_pr_labels = ["T-compiler"]
# The regression MUST have this label
required_issue_labels = "regression-from-stable-to-beta"
# if the above conditions matches, the PR will receive these labels
add_labels = ["beta-nominated"]

[backport.bar]
required_pr_labels = ["T-compiler"]
required_issue_labels = "regression-from-stable-to-stable"
add_labels = ["beta-nominated", "stable-nominated"]

[backport.baz]
required_pr_labels = ["T-libs", "T-libs-api"]
required_issue_labels = "regression-from-stable-to-stable"
add_labels = ["stable-nominated"]

The workflow that models the decision to add the backport label is:

  1. Someone files a regression #123, with a t-label (ex. "T-compiler")
  2. Contributor opens PR #456, adds comment "Fixes #123"
  3. triagebot receives the event "new PR"
  4. triagebot parses the opening comment and retrieves originating regression(s)
    3a. checks if PR has the required team labels (reads from required_pr_labels), loads the appropriate config
    3b. checks if issue has a regression-from-* label (reads from required_issue_labels)
    3c. checks the P-label of the regression, discard P-low and P-medium regressions
  5. triagebot adds backport label(s) to PR Implement the prioritize command #456 (reads from add_labels)

TODOs

Situations not yet handled where this handler should trigger as well:

  • PR is opened without a T-label (can that happen? or is that automatically applied?), user adds a T-label to the PR later
  • The regression receives a P-label when the PR fixing it already exists
  • The expected marker text ("Fixes, resolves, etc.") is added later
  • probably other cases ...

This work supersedes #1380 (Important: before merge this commit should be Co-authored1)

r?

Footnotes

  1. Not doing now to avoid spamming the original author with multiple forced git push 🙂

@rust-lang rust-lang deleted a comment from rustbot Jun 30, 2025
@apiraino apiraino force-pushed the auto-nominate-backports branch 7 times, most recently from 7a37ed9 to 9167286 Compare July 8, 2025 14:23
@apiraino apiraino force-pushed the auto-nominate-backports branch 2 times, most recently from 2484587 to eb5b382 Compare July 9, 2025 14:45
@apiraino apiraino requested a review from Urgau July 9, 2025 14:48
@apiraino apiraino force-pushed the auto-nominate-backports branch 2 times, most recently from dc9450f to 4f7b659 Compare July 14, 2025 12:23
@apiraino apiraino force-pushed the auto-nominate-backports branch from 4f7b659 to 9682868 Compare July 16, 2025 11:46
for caps in CLOSES_ISSUE_REGEXP.captures_iter(&event.issue.body) {
let id = caps
.name("issue_num")
.expect("Failed to cast issue_num to string")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.expect("Failed to cast issue_num to string")
.with_context(|| format!("failed to get issue_num from {caps:?}"))?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change actually compile for you? I can't make it compile and it seems to be a bit fiddly to make it work.

Details


error[E0277]: `?` couldn't convert the error to `std::string::String`
   --> src/handlers/backport.rs:106:79
    |
106 |             .with_context(|| format!("failed to get issue_num from {caps:?}"))?;
    |              -----------------------------------------------------------------^ the trait `From<anyhow::Error>` is not implemented for `std::string::String`
    |              |
    |              this can't be annotated with `?` because it has type `Result<_, anyhow::Error>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait

Copy link
Member

@Urgau Urgau Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't try it locally but I'm surprised it doesn't work.

Looking around, I think it's due to handle_input not returning anyhow::Result but std-Result.

@apiraino apiraino force-pushed the auto-nominate-backports branch from 9682868 to bcb1667 Compare July 17, 2025 11:03
@apiraino apiraino force-pushed the auto-nominate-backports branch from bcb1667 to 18cd1ce Compare July 17, 2025 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants