merge_pull_request: tolerate merge_method alias, avoid opaque 422 on empty style #3

Closed
opened 2026-06-04 14:10:16 +00:00 by Phil · 0 comments
Owner

Symptom

merge_pull_request reads only the style argument. A caller passing the GitHub-style merge_method (a very natural name) leaves style empty → MergeStyle("") → Forgejo returns HTTP 422, surfaced as the opaque merge pull request: server returned HTTP 422 (expected 200).

That message is indistinguishable from a genuine branch-protection / required-check rejection, so it sends you chasing phantom gate causes (required reviews, status-context mismatch, dispatch rituals) instead of the real one-word param mistake. This cost a full debugging session on 2026-06-04, and had bitten before in another session.

Fix

  • Accept merge_method / merge_style as aliases for style.
  • Default an empty style to merge (the --no-ff repo norm, KV-021 §7).
  • Validate the style up front and return a clear error (invalid merge style %q: use one of merge|rebase|rebase-merge|squash) instead of forwarding a malformed request.
  • Annotate the genuine-422 error so a real gate rejection is no longer confused with a param mistake (and explicitly warns against force_merge).
  • Drop Required() from style in the tool schema (now optional, defaults to merge).

Acceptance

  • Calling with merge_method: "merge" merges (no 422).
  • Calling with no style merges via merge.
  • Calling with an invalid style returns a clear, actionable error, not a raw 422.
## Symptom `merge_pull_request` reads only the `style` argument. A caller passing the GitHub-style `merge_method` (a very natural name) leaves `style` empty → `MergeStyle("")` → Forgejo returns **HTTP 422**, surfaced as the opaque `merge pull request: server returned HTTP 422 (expected 200)`. That message is **indistinguishable from a genuine branch-protection / required-check rejection**, so it sends you chasing phantom gate causes (required reviews, status-context mismatch, dispatch rituals) instead of the real one-word param mistake. This cost a full debugging session on 2026-06-04, and had bitten before in another session. ## Fix - Accept `merge_method` / `merge_style` as aliases for `style`. - Default an empty `style` to `merge` (the `--no-ff` repo norm, KV-021 §7). - Validate the style up front and return a **clear** error (`invalid merge style %q: use one of merge|rebase|rebase-merge|squash`) instead of forwarding a malformed request. - Annotate the genuine-422 error so a real gate rejection is no longer confused with a param mistake (and explicitly warns against force_merge). - Drop `Required()` from `style` in the tool schema (now optional, defaults to merge). ## Acceptance - Calling with `merge_method: "merge"` merges (no 422). - Calling with no style merges via `merge`. - Calling with an invalid style returns a clear, actionable error, not a raw 422.
Phil closed this issue 2026-06-04 14:10:54 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Phil/forgejo-mcp#3
No description provided.