fix(discord): bound application summary probes

This commit is contained in:
Peter Steinberger
2026-04-29 19:04:22 +01:00
parent 950a9b5500
commit a81e3ee888
2 changed files with 22 additions and 1 deletions

View File

@@ -1,6 +1,10 @@
import { withFetchPreconnect } from "openclaw/plugin-sdk/test-env";
import { describe, expect, it } from "vitest";
import { fetchDiscordApplicationId, resolveDiscordPrivilegedIntentsFromFlags } from "./probe.js";
import {
fetchDiscordApplicationId,
fetchDiscordApplicationSummary,
resolveDiscordPrivilegedIntentsFromFlags,
} from "./probe.js";
import { jsonResponse } from "./test-http-helpers.js";
describe("resolveDiscordPrivilegedIntentsFromFlags", () => {
@@ -58,6 +62,22 @@ describe("resolveDiscordPrivilegedIntentsFromFlags", () => {
expect(calls).toBe(2);
});
it("does not retry Cloudflare HTML rate limits during application summary probes", async () => {
let calls = 0;
const fetcher = withFetchPreconnect(async () => {
calls += 1;
return new Response("<html><title>Error 1015</title></html>", {
status: 429,
headers: { "content-type": "text/html" },
});
});
await expect(
fetchDiscordApplicationSummary("unparseable.token", 1_000, fetcher),
).resolves.toBeUndefined();
expect(calls).toBe(1);
});
it("derives application id from parseable tokens before probing REST", async () => {
let calls = 0;
const fetcher = withFetchPreconnect(async () => {

View File

@@ -49,6 +49,7 @@ async function fetchDiscordApplicationMe(
"/oauth2/applications/@me",
normalized,
createDiscordTimeoutFetch(fetcher, timeoutMs),
{ retry: { attempts: 1 } },
);
} catch {
return undefined;