Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/merge-gate/check_bot_anchoring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ for r in reviews:
if commit_oid != head_oid:
continue
body = r.get('body') or ''
has_inline = r.get('includesCreatedEdit', False)
has_inline = (r.get('comments') or {}).get('totalCount', 0) > 0
if body.strip() or has_inline:
print('SUCCESS: anchored substantive bot review found')
sys.exit(0)
Expand Down
15 changes: 15 additions & 0 deletions tests/fixtures/merge_gate/pr_inline_only.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"number": 218,
"headRefOid": "abc123def456",
"reviews": [
{
"author": {"login": "coderabbitai"},
"state": "COMMENTED",
"body": "",
"commit": {"oid": "abc123def456"},
"comments": {"totalCount": 3},
"includesCreatedEdit": false,
"submittedAt": "2026-07-28T12:21:45Z"
}
]
}
37 changes: 37 additions & 0 deletions tests/test_merge_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,43 @@ def test_human_only_fails(tmp_path):
assert result.stdout.startswith("FAILED:")


def test_inline_only_review_rejected_by_buggy_logic(tmp_path):
fixture = _read("pr_inline_only.json")
_make_fake_gh(str(tmp_path), pr=fixture)
env = os.environ.copy()
env["PATH"] = str(tmp_path) + ":" + env.get("PATH", "")

# Reconstruct the pre-fix logic that relied on includesCreatedEdit
with open(os.path.join("scripts", "merge-gate", "check_bot_anchoring.sh")) as f:
buggy_script = f.read().replace(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Regression test uses string replacement to reconstruct the buggy logic

If the implementation is later refactored to a different approach (e.g., extracting the inline-comment check to a helper function or using a different field), the .replace() silently fails to match. The buggy script would then contain the current fixed logic, and because the fixture's comments.totalCount is 3, the test would unexpectedly return SUCCESS instead of FAILED — masking a regression in the test itself.

Consider asserting against the old field directly (includesCreatedEdit) instead of patching the source string, or adding a dedicated fixture that has comments: null to also cover the missing-field edge case.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

"has_inline = (r.get('comments') or {}).get('totalCount', 0) > 0",
"has_inline = r.get('includesCreatedEdit', False)",
)
buggy_path = os.path.join(str(tmp_path), "buggy.sh")
with open(buggy_path, "w") as f:
f.write(buggy_script)

result = subprocess.run(
["bash", buggy_path, "218"],
capture_output=True,
text=True,
env=env,
)
assert result.returncode == 10, result.stdout + result.stderr
assert result.stdout.startswith("FAILED:")


def test_inline_only_review_accepted_by_fix(tmp_path):
result = _run(
"check_bot_anchoring.sh",
["218"],
str(tmp_path),
pr=_read("pr_inline_only.json"),
)
assert result.returncode == 0, result.stdout + result.stderr
assert result.stdout.startswith("SUCCESS:")


def test_rate_limited_fails(tmp_path):
result = _run(
"check_fake_green.sh",
Expand Down