Skip to content

Commit dbe58f2

Browse files
fix(github): only GitHub's own abuse-detection wording pauses the host
A proxy page that says "abuse detection" is a refusal, not a GitHub limit. GitHub's legacy answer always says "abuse detection mechanism", so match that phrase. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3d9a534 commit dbe58f2

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎packages/source-control-github/src/server/GitHubRequestPolicy.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ function retryAtFrom(
149149

150150
/**
151151
* HTTP 200 GraphQL rate limits use RATE_LIMITED or untyped errors with quota headers. A 403 is a
152-
* limit only when GitHub names one, by an exhausted quota or its body or GraphQL errors (older hosts
153-
* say "abuse detection"): a proxy in front of GitHub Enterprise can refuse with `Retry-After` alone.
152+
* limit only when its quota, body or GraphQL errors name one (older hosts say "abuse detection
153+
* mechanism"): a proxy in front of GitHub Enterprise can refuse with `Retry-After` alone.
154154
*/
155155
export function isRateLimited(input: {
156156
readonly status: number;
@@ -177,7 +177,7 @@ export function isRateLimited(input: {
177177
}
178178

179179
function namesLimit(text: unknown): boolean {
180-
return typeof text === "string" && /rate limit|abuse detection/i.test(text);
180+
return typeof text === "string" && /rate limit|abuse detection mechanism/i.test(text);
181181
}
182182

183183
export type GitHubAnswer<A> = {

‎packages/source-control-github/src/server/GitHubRest.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,13 @@ describe("GitHubRest", () => {
511511
});
512512

513513
it.effect("reads a proxy's 403 with Retry-After as a refusal and keeps the host open", () => {
514+
const pages = [
515+
"<html><head><title>403 Forbidden</title></head><body>nginx</body></html>",
516+
"<html><body>Request blocked by proxy abuse detection; contact your administrator</body></html>",
517+
];
514518
const { layer, requests } = harness(
515519
() =>
516-
new Response("<html><head><title>403 Forbidden</title></head><body>nginx</body></html>", {
520+
new Response(pages.shift(), {
517521
status: 403,
518522
headers: { "content-type": "text/html", "retry-after": "5" },
519523
}),

0 commit comments

Comments
 (0)