fix: check merged bool in MergePullRequestFn #113

Merged
synath merged 0 commits from refs/pull/113/head into main 2026-05-02 10:03:13 +00:00
synath commented 2026-05-02 07:24:31 +00:00 (Migrated from codeberg.org)

Problem

MergePullRequestFn discarded all three return values from the SDK's MergePullRequest:

_, _, err := forgejo.Client().MergePullRequest(owner, repo, int64(index), opt)

The SDK returns (bool, *Response, error) where the bool is statusCode == 200. Any non-200 HTTP response from Forgejo — including 405 (branch protection), 409 (conflict), 403 (forbidden) — produced err == nil, causing the tool to always report "Pull request merged successfully" even when the merge didn't happen.

Fix

Capture and check the bool return value. If the merge didn't return 200 and merge_when_checks_succeed is not set, return an error with the actual HTTP status code.

Discovered via

Using this tool against a repo with a branch protection rule that blocked the merge. The false positive made it impossible to diagnose why the merge wasn't landing — we only discovered the real error (405 User not allowed to merge PR) after adding this check.

## Problem `MergePullRequestFn` discarded all three return values from the SDK's `MergePullRequest`: ```go _, _, err := forgejo.Client().MergePullRequest(owner, repo, int64(index), opt) ``` The SDK returns `(bool, *Response, error)` where the bool is `statusCode == 200`. Any non-200 HTTP response from Forgejo — including 405 (branch protection), 409 (conflict), 403 (forbidden) — produced `err == nil`, causing the tool to always report "Pull request merged successfully" even when the merge didn't happen. ## Fix Capture and check the bool return value. If the merge didn't return 200 and `merge_when_checks_succeed` is not set, return an error with the actual HTTP status code. ## Discovered via Using this tool against a repo with a branch protection rule that blocked the merge. The false positive made it impossible to diagnose why the merge wasn't landing — we only discovered the real error (`405 User not allowed to merge PR`) after adding this check.
Sign in to join this conversation.
No reviewers
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
agentic-forges/forgejo-mcp!113
No description provided.