From 410cf32cfec520dfd7e6783d85bf751bc6fbcfe8 Mon Sep 17 00:00:00 2001 From: m3taversal Date: Fri, 13 Mar 2026 17:38:00 +0000 Subject: [PATCH] leo: handle non-JSON 200 from Forgejo merge API Forgejo returns 200 with HTML content-type on successful merge instead of JSON. Our API helper threw on resp.json(), causing merge to report failure even though the PR merged. Now treats non-JSON 200 as success. This was causing PRs #732 and #789 to show as conflict in our DB while actually merged on Forgejo, and tripping the merge circuit breaker. Pentagon-Agent: Leo <294C3CA1-0205-4668-82FA-B984D54F48AD> --- lib/forgejo.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/forgejo.py b/lib/forgejo.py index 7bd024f..7a829cc 100644 --- a/lib/forgejo.py +++ b/lib/forgejo.py @@ -38,6 +38,12 @@ async def api(method: str, path: str, body: dict = None, token: str = None): return None if resp.status == 204: return {} + # Forgejo sometimes returns 200 with HTML (not JSON) on merge success. + # Treat 200 with non-JSON content-type as success rather than error. + content_type = resp.content_type or "" + if "json" not in content_type: + logger.debug("Forgejo API %s %s → %d (non-JSON: %s), treating as success", method, path, resp.status, content_type) + return {} return await resp.json() except Exception as e: logger.error("Forgejo API error: %s %s → %s", method, path, e)