-
Notifications
You must be signed in to change notification settings - Fork 2
fix: resolve issue #284 #287
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,13 @@ def __init__(self, keyword: str): | |
| self.keyword = keyword | ||
|
|
||
|
|
||
| class IncorrectSyntax(Error): | ||
| """An option was called with arguments using a wrong syntax.""" | ||
| def __init__(self, keyword: str): | ||
| super().__init__() | ||
| self.keyword = keyword | ||
|
|
||
|
|
||
| class NotFound(Error): | ||
| """The requested command or option doesn't exist.""" | ||
| def __init__(self, keyword: str): | ||
|
|
@@ -445,6 +452,11 @@ def handle_commands(self, job, text, prefix, privileged=False): | |
| return | ||
| raise NotFound(key) | ||
| if not isinstance(command, Command): | ||
| if slash_shorthand and args and not args[0].startswith("="): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Warning — One malformed variant is still ignored silently.
|
||
| # An option followed by free-form arguments (e.g. | ||
| # ``/after_pull_request 1509``) is not a valid option | ||
| # declaration: options take their argument as ``key=value``. | ||
| raise IncorrectSyntax(key) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: the |
||
| return | ||
|
|
||
| if command.privileged and not privileged: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,9 @@ | |
| from bert_e.job import handler, CommitJob, PullRequestJob, QueuesJob | ||
| from bert_e.lib.cli import confirm | ||
| from bert_e.lib.simplecmd import CommandError | ||
| from bert_e.reactor import Reactor, NotFound, NotPrivileged, NotAuthored | ||
| from bert_e.reactor import ( | ||
| Reactor, NotFound, NotPrivileged, NotAuthored, IncorrectSyntax | ||
| ) | ||
| from ..git_utils import push, clone_git_repo | ||
| from ..pr_utils import find_comment, notify_user | ||
| from .branches import ( | ||
|
|
@@ -360,6 +362,11 @@ def handle_comments(job): | |
| active_options=job.active_options, command=err.keyword, | ||
| author=author, self_pr=(author == pr_author), comment=text | ||
| ) from err | ||
| except IncorrectSyntax as err: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Warning — The dependency is silently dropped after one reply, so the PR can merge too early. The new error comes only from the commands loop, and that loop reads only the comments posted after the robot's last message ( |
||
| raise messages.IncorrectCommandSyntax( | ||
| robot=job.settings.robot, keyword=err.keyword, | ||
| active_options=job.active_options | ||
| ) from err | ||
|
|
||
|
|
||
| def check_commit_diff(job): | ||
|
|
||
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.
🔴 Critical — Valid multi-option comments get rejected and block the merge run.
The new check raises
IncorrectSyntaxfor any/-shorthand option that has trailing tokens not starting with=. That includes valid multi-option comments thathandle_optionsaccepts on purpose, through its regex^/[\w=]+([\s,.\-:;|+]+/[\w=]+)*\s*$. For/approve /bypass_jira_checkor/approve, /after_pull_request=3,handle_commandsparses keyapprovewith args['/bypass_jira_check'], and'/bypass_jira_check'does not start with=, so it raisesIncorrectSyntax('approve'). I ran both comments through a Reactor subclass:handle_optionsapplied them without error, andhandle_commandsraised IncorrectSyntax each time. Posted after Bert-E's last message, these valid comments now stop the run with an "Incorrect command syntax" reply that blamesapprove. Before this change they were accepted. The check should reject only args that are not further/-prefixed option tokens, or should reuse the options regex.