Skip to content

fix: resolve issue #284 - #287

Closed
matthiasL-scality wants to merge 1 commit into
mainfrom
fix/issue-284
Closed

matthiasL-scality wants to merge 1 commit into
mainfrom
fix/issue-284

Conversation

@matthiasL-scality

Copy link
Copy Markdown
Contributor

Reply with an incorrect-syntax error (with usage hint) when an option is given as /after_pull_request 1509 instead of /after_pull_request=1509, rather than silently ignoring it. Fixes #284

@matthiasL-scality
matthiasL-scality requested a review from a team as a code owner September 30, 2026 13:00

@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 · 🟡 2 warnings

🔍 Full review · 5 files reviewed

Verification
  • /after_pull_request=1509 still passes handle_commands: the command regex splits it into key after_pull_request and args ['=1509'], so no error is raised.
  • @bert-e after_pull_request N is unaffected by the new branch, which is guarded by slash_shorthand; that form still fails through the TypeError in handle_options.
  • IncorrectSyntax.keyword is passed on to the template, and the template guards its hint with keyword is defined and keyword, so older callers that don't pass a keyword still render.

The diff adds a unit test in bert_e/tests/unit/test_reactor.py and an integration test test_after_pull_request_slash_space_syntax in test_bert_e.py. Neither test covers multi-option / comments (e.g. /approve /bypass_jira_check) going through handle_commands, or a second run after the error reply has been posted.

Review details
  • Commit: 4f7224f
  • 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 slash_shorthand and args and not args[0].startswith("="):

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 — Valid multi-option comments get rejected and block the merge run.

The new check raises IncorrectSyntax for any /-shorthand option that has trailing tokens not starting with =. That includes valid multi-option comments that handle_options accepts on purpose, through its regex ^/[\w=]+([\s,.\-:;|+]+/[\w=]+)*\s*$. For /approve /bypass_jira_check or /approve, /after_pull_request=3, handle_commands parses key approve with args ['/bypass_jira_check'], and '/bypass_jira_check' does not start with =, so it raises IncorrectSyntax('approve'). I ran both comments through a Reactor subclass: handle_options applied them without error, and handle_commands raised IncorrectSyntax each time. Posted after Bert-E's last message, these valid comments now stop the run with an "Incorrect command syntax" reply that blames approve. 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.

active_options=job.active_options, command=err.keyword,
author=author, self_pr=(author == pr_author), comment=text
) from err
except IncorrectSyntax as 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.

🟡 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 (if author == job.settings.robot: return). Once Bert-E posts the IncorrectCommandSyntax reply, the next run stops at that reply and never sees /after_pull_request 1509 again. The options loop doesn't catch it either: the comment fails the /-shorthand regex in handle_options because the second token has no /, so it is dropped silently. The next run then goes ahead as if the dependency had never been declared and can merge the PR before PR 1509. The message says "edit or delete the comment so I can move on", but the block lasts for one run only. Compare the @bert-e after_pull_request N form, which fails inside handle_options (a TypeError) on every run, so its block persists.

Comment thread bert_e/reactor.py
return
raise NotFound(key)
if not isinstance(command, Command):
if slash_shorthand and args and not args[0].startswith("="):

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 — One malformed variant is still ignored silently.

/after_pull_request = 1509 (spaces around =) gives args ['=', '1509'], and args[0].startswith('=') passes, so no error is raised. handle_options also drops this form (verified), so the malformed declaration is still ignored silently, the same failure mode issue #284 describes.

Comment thread bert_e/reactor.py
# 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)

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: the handle_commands docstring Raises section (line ~415) only documents NotFound and NotPrivileged. Consider adding IncorrectSyntax to that list now that this method can raise it.

— Claude Code

@claude

claude Bot commented Sep 30, 2026

Copy link
Copy Markdown

LGTM — clean fix for #284. The new IncorrectSyntax exception, template hint, and tests all look correct. One minor suggestion posted inline:

- The handle_commands docstring Raises section should mention the new IncorrectSyntax exception for completeness.

Review by Claude Code

@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.22%. Comparing base (cfe0bc2) to head (4f7224f).

Files with missing lines Patch % Lines
bert_e/tests/unit/test_reactor.py 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #287      +/-   ##
==========================================
+ Coverage   90.21%   90.22%   +0.01%     
==========================================
  Files          82       82              
  Lines       11293    11320      +27     
==========================================
+ Hits        10188    10214      +26     
- Misses       1105     1106       +1     
Flag Coverage Δ
integration 87.70% <100.00%> (+0.02%) ⬆️
tests 87.67% <100.00%> (+0.02%) ⬆️
tests-BuildFailedTest 25.69% <22.22%> (-0.02%) ⬇️
tests-QuickTest 32.99% <22.22%> (-0.03%) ⬇️
tests-RepositoryTests 25.38% <22.22%> (-0.02%) ⬇️
tests-TaskQueueTests 49.55% <27.77%> (-0.06%) ⬇️
tests-TestBertE 67.04% <100.00%> (+0.06%) ⬆️
tests-TestQueueing 51.62% <22.22%> (-0.07%) ⬇️
tests-api-mock 14.41% <0.00%> (-0.04%) ⬇️
tests-noqueue 78.42% <100.00%> (+0.04%) ⬆️
tests-noqueue-BuildFailedTest 25.69% <22.22%> (-0.02%) ⬇️
tests-noqueue-QuickTest 32.99% <22.22%> (-0.03%) ⬇️
tests-noqueue-RepositoryTests 25.38% <22.22%> (-0.02%) ⬇️
tests-noqueue-TaskQueueTests 49.55% <27.77%> (-0.06%) ⬇️
tests-noqueue-TestBertE 63.61% <100.00%> (+0.05%) ⬆️
tests-noqueue-TestQueueing 25.40% <22.22%> (-0.02%) ⬇️
tests-server 26.67% <10.34%> (-0.05%) ⬇️
unittests 43.45% <58.62%> (+0.03%) ⬆️
utests 29.17% <58.62%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matthiasL-scality
matthiasL-scality deleted the fix/issue-284 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

1 participant