-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Give better error message when merge fails to find any rules #84160
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/84160
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit d865825: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making this change!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not ask people to file an issue every time merge rules are not found
Nor do advice people to rebase, it should not help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are great, but it doesn't really address #84147, right?
Perhaps those could go in another PR?
We already have most of the features you mention in #84147 I think:
The only reason #84147 has such cryptic message was that it failed to find the merge rule (fixed by #84084). Thus, the default reject message was shown. So I think we just need to be clearer here |
Ah, I see, thanks for the explanation. The code does look like it should have done the right thing. I'll try to re-merge that PR (which should still fail due to the missing approval) to verify that a better error is shown. |
@pytorchbot merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps two usecases you want to cover:
- if
len(merge_rules) == 0
mergebot should print a message saying that "Merges are not allowed into repository without a rules" - Default message should say "No rules find to match PR , please report this issue to ..." (Also, can we specify a default issue message?)
@pytorchbot successfully started a merge job. Check the current status here and land check progress here. |
Merge failed |
Fixes #84147 and pytorch/test-infra#421. * If merge rule file is missing, the follow error will be printed out with `rules_path` replaced by the actual path like `merge_rules.yaml`. The most likely reason here is that we are doing something with `trymerge` intentionally. ``` merge_rules.yml does not exist, no merge rule can be found. Please run `@pytorchbot rebase -s` to rebase the PR onto PyTorch stable branch before trying to merge again. ``` * If any runtime error occurs or no rule matches, this is very likely an error. So we will provide the link to submit a [bug report](https://github.com/pytorch/pytorch/issues/new?labels=module%3A%20ci&template=bug-report.yml) to DevX ``` PR 12345 does not match any merge rules. This should not happen. Please help file a [bug report]({issue_link}) to PyTorch DevX Team with the PR number. ``` Pull Request resolved: #84160 Approved by:
Fix the message. On the other hand, I'll work on the change to not start land validation if the PR hasn't been reviewed. This looks quite different than this one, so I think it would be best to keep that in a separate PR. |
.github/scripts/trymerge.py
Outdated
print(f"{rules_path} does not exist, returning empty rules") | ||
return [] | ||
reject_reason = (f"{rules_path} does not exist") | ||
raise RuntimeError(reject_reason) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not needed with later change, is it?
.github/scripts/trymerge.py
Outdated
reject_reason = (f"No rules find to match PR, " | ||
f"please [report]{issue_link} this issue to DevX team") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use f
decorator in front of string literals. Also, do not rely on the implicit concatenation, but rather add +
operator or just keep it on the single line (or line length is 120 characters, isn't it?)
reject_reason = (f"No rules find to match PR, " | |
f"please [report]{issue_link} this issue to DevX team") | |
reject_reason = ("No rules find to match PR, " | |
f"please [report]{issue_link} this issue to DevX team") |
.github/scripts/trymerge.py
Outdated
try: | ||
rules = read_merge_rules(repo, pr.org, pr.project) | ||
except Exception as error: | ||
# Any error here means that the script couldn't load the merge rules for | ||
# some reasons, and the reject message should say so | ||
raise RuntimeError(f"{reject_reason}: {error}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't having a generic exception catching is a bad practice (i.e. this function should already raise correct errors
try: | |
rules = read_merge_rules(repo, pr.org, pr.project) | |
except Exception as error: | |
# Any error here means that the script couldn't load the merge rules for | |
# some reasons, and the reject message should say so | |
raise RuntimeError(f"{reject_reason}: {error}") | |
rules = read_merge_rules(repo, pr.org, pr.project) |
.github/scripts/trymerge.py
Outdated
project=pr.project, | ||
labels=["module: ci"], | ||
) | ||
reject_reason = (f"No rules find to match PR, " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
reject_reason = (f"No rules find to match PR, " | |
reject_reason = (f"No rules found to match PR, " |
.github/scripts/trymerge.py
Outdated
raise RuntimeError(f"{reject_reason}: {error}") | ||
|
||
if not rules: | ||
reject_reason = "Merges are not allowed into repository without a rules." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Without a rules" is a bit hard to understand. Can we make the suggested action more explicit?
Perhaps:
reject_reason = "Merges are not allowed into repository without a rules." | |
reject_reason = "No matching merge rules found in merge_rules.yaml. Please fix file contents to ensure we have a valid merge rule are defined." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps "Rejecting the merge as no rules are defined for the repository."
Also, let's not hardcode file name multiple times in the code, but rather move it into top level variable or something
Co-authored-by: Nikita Shulga <nikita.shulga@gmail.com>
Co-authored-by: Nikita Shulga <nikita.shulga@gmail.com>
…failed-merge-helper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small nit. Otherwise looking good!
Co-authored-by: Zain Rizvi <ZainRizvi@users.noreply.github.com>
@pytorchbot merge -g |
@pytorchbot successfully started a merge job. Check the current status here. |
Hey @huydhn. |
…#84160) Summary: Fixes #84147 and pytorch/test-infra#421. * If merge rule file is missing or fails to load for whatever reasons: ``` No rules find to match PR, please [report]{issue_link} this issue to DevX team. ``` * If the list of rules is empty: ``` Merges are not allowed into repository without a rules. ``` Pull Request resolved: #84160 Approved by: https://github.com/ZainRizvi, https://github.com/malfet Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/adc54dc2195fbfe37b2f01649b8788314382a9be Reviewed By: mehtanirav Differential Revision: D39123427 Pulled By: huydhn fbshipit-source-id: 69b02163b76eefac2bd64758713f65bbcb287ac4
Fixes #84147 and pytorch/test-infra#421.