From 9e3d19b1bc58b034266e0f81205627d4d9aadf22 Mon Sep 17 00:00:00 2001 From: Mikkel Jarlund Date: Fri, 13 Nov 2026 09:06:58 +0100 Subject: [PATCH] fix(server): do not inject rateLimit into mutations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rateLimit is a field on the Query root. injectRateLimit added it as a sibling of every operation's root fields, so every mutation document failed with "Field 'rateLimit' doesn't exist on type 'Mutation'" — approve, merge, label edit and label remove were all dead. Skip injection for mutation operations. Queries (shorthand, named, with leading fragments) still get the reading. --- server/github/rate-limit.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/github/rate-limit.ts b/server/github/rate-limit.ts index a091dc1..1b534da 100644 --- a/server/github/rate-limit.ts +++ b/server/github/rate-limit.ts @@ -99,6 +99,12 @@ function skipFragments(query: string): number { */ export function injectRateLimit(query: string): string { const operationStart = skipFragments(query); + // `rateLimit` is a field on the Query root only. Injecting it into a mutation + // makes GitHub reject the whole document — "Field 'rateLimit' doesn't exist on + // type 'Mutation'" — which failed every approve, merge and label action. + if (/^\s*mutation\b/.test(query.slice(operationStart))) { + return query; + } const braceIndex = query.indexOf("{", operationStart); if (braceIndex === -1) return query; return `${query.slice(0, braceIndex + 1)}\n rateLimit { cost remaining limit resetAt }${query.slice(braceIndex + 1)}`;