Skip to content

fix: resolve issue #284 - #285

Closed
matthiasL-scality wants to merge 1 commit into
mainfrom
fix/issue-284-after-pull-request-error-message
Closed

matthiasL-scality wants to merge 1 commit into
mainfrom
fix/issue-284-after-pull-request-error-message

Conversation

@matthiasL-scality

Copy link
Copy Markdown
Contributor

Fixes #284. /after_pull_request 1509 was silently ignored. It now replies with an incorrect-syntax message explaining that options use key=value.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@matthiasL-scality
matthiasL-scality requested a review from a team as a code owner September 30, 2026 12:34

@upsun-dispatch upsun-dispatch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

1 critical finding in this review. Details below.

Caution

Changes requested — 🔴 1 critical · 🟡 1 warning · 🔵 1 minor point

🔍 Full review · 4 files reviewed

Verification
  • The /after_pull_request 1509 form fails the strict slash regex in handle_options, so only the new handle_commands branch handles it.
  • A bare /after_pull_request or @bert-e approve with nothing after it still returns silently from handle_commands.
  • The commands loop in handle_comments stops at the robot's last comment, so the new error is not re-raised once the bot has replied.

The new unit test in test_reactor.py covers only the positional-argument case. No test checks that key=value or multi-option comments still pass handle_commands, which is how the regression gets through. Unit and integration tests run through tox in the main.yaml workflow; the existing after_pull_request= cases in test_bert_e.py may catch the regression there.

Review details
  • Commit: d968e43
  • Model: claude-opus-5-5

Review 1 of 10 for this pull request · View the full run

Comment thread bert_e/reactor.py
return
raise NotFound(key)
if not isinstance(command, Command):
if args:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Critical — Correct key=value and multi-option comments now block every PR that uses them.

The if args: guard also fires on option comments that are valid. The command regex (?P<command>[A-Za-z_]+[^= ,])(?P<args>.*) stops the key before =, a space or a comma, so args is non-empty for every option that has a value or is followed by another option. I ran it: @bert-e after_pull_request=1509, /after_pull_request=12, @bert-e approve wait, @bert-e: approve, wait and /approve /wait all raise IncorrectSyntax now. Before this change they returned silently. The docstring documents exactly these forms as valid ({prefix}option1=val1 option2). handle_comments turns the exception into IncorrectCommandSyntax, which blocks the PR. Any user who posts the documented key=value syntax, or several options in one comment, gets an error reply and the PR does not progress. The check should only fire when the key is followed by whitespace and then a bare token without =, e.g. by checking that the remainder after the key does not start with = and that no token is itself a registered option.

author=author, self_pr=(author == pr_author), comment=text
) from err
except IncorrectSyntax as err:
raise messages.IncorrectCommandSyntax(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Warning — The usage hint in the new error reply leaves out the bot name.

The new messages.IncorrectCommandSyntax(...) is built without robot=. The template renders @{{ robot }} option[=argument], and neither TemplateException nor message.md fills robot in. The reply therefore shows the correct usage as @ option[=argument], with no bot name. The existing after_pull_request handler in commands.py passes robot=job.bert_e.client.login for this reason.


{% block message %}
It seems that your command syntax is incorrect. The correct usage is:
It seems that your command syntax is incorrect.{% if extra_message %} {{ extra_message }}{% endif %} The correct usage is:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Minor — Users see confusing internal Python error text in bot replies.

The template now renders extra_message. The existing except TypeError path in handle_comments (around line 338) passes extra_message=str(err), and until now that text was never shown. After this change, raw Python TypeError text such as a() takes from 1 to 2 positional arguments but 3 were given is posted verbatim into PR comments. That text exposes internal handler names and can come from bugs unrelated to user syntax.

"'%s=<value>' instead." % (
err.keyword, err.keyword),
active_options=job.active_options
) from err

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The template uses robot variable but this handler does not pass robot. With StrictUndefined in template_loader.py, this will crash at render time when /after_pull_request 1509 is used. Add robot=job.settings.robot to the kwargs. — Claude Code


{% block message %}
It seems that your command syntax is incorrect. The correct usage is:
It seems that your command syntax is incorrect.{% if extra_message %} {{ extra_message }}{% endif %} The correct usage is:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The template now checks extra_message with a plain if-test, but Jinja2 StrictUndefined raises UndefinedError when the variable is not passed at all. The existing path in commands.py:272 raises IncorrectCommandSyntax without extra_message, so this template change will crash there. Use 'if extra_message is defined and extra_message' instead. — Claude Code

@claude

claude Bot commented Sep 30, 2026

Copy link
Copy Markdown

Two template rendering bugs that will crash at runtime under Jinja2 StrictUndefined:

  • Missing robot parameter (gitwaterflow/init.py:365-370): the new IncorrectSyntax handler raises IncorrectCommandSyntax without passing robot, but the template uses {{ robot }}. Fix: add robot=job.settings.robot to the kwargs.
  • Undefined extra_message check (incorrect_command_syntax.md:8): {% if extra_message %} crashes when extra_message is not provided (e.g. from commands.py:272). Fix: use {% if extra_message is defined and extra_message %}.

Review by Claude Code

@matthiasL-scality
matthiasL-scality deleted the fix/issue-284-after-pull-request-error-message branch October 2, 2026 05:47
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.

wait for another PR

2 participants