fix(mcp): fail closed when merger lease cannot resolve live PR head

gitea_acquire_merger_pr_lease previously continued when GET /pulls returned
an empty head SHA. Fail closed so exact-head scoping never proceeds with an
unresolvable live head. Add regression coverage for empty head payloads.

Fixes #718
Refs #723
This commit is contained in:
2026-07-17 13:25:34 -04:00
parent 4a160e0e0c
commit 29c2cf2ef6
2 changed files with 60 additions and 1 deletions
+14 -1
View File
@@ -10821,7 +10821,20 @@ def gitea_acquire_merger_pr_lease(
or ""
)
live_head = str(live_head).strip()
if live_head and live_head != head_pin:
# Fail closed when live PR head cannot be resolved — never proceed with
# an unpinned/unknown head even if candidate_head was supplied (#718).
if not live_head:
return {
"success": False,
"acquired": False,
"reasons": [
"live PR head could not be resolved from GET /pulls response "
"(exact-head scoping; fail closed)"
],
"live_head": None,
"candidate_head": head_pin,
}
if live_head != head_pin:
return {
"success": False,
"acquired": False,