惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
Recent Announcements
Recent Announcements
A
About on SuperTechFans
U
Unit 42
MyScale Blog
MyScale Blog
J
Java Code Geeks
博客园_首页
Blog — PlanetScale
Blog — PlanetScale
D
Docker
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
量子位
月光博客
月光博客
G
Google Developers Blog
V
V2EX
博客园 - 聂微东
宝玉的分享
宝玉的分享
IT之家
IT之家
Vercel News
Vercel News

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(chutes): bound oauth token error bodies · openclaw/op...
vincentkoc · 2026-06-19 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -2,6 +2,42 @@

22

import { describe, expect, it, vi } from "vitest";

33

import { loginChutes } from "./oauth.js";

44
5+

function boundedErrorResponse(body: string, status = 500): {

6+

response: Response;

7+

cancel: ReturnType<typeof vi.fn>;

8+

releaseLock: ReturnType<typeof vi.fn>;

9+

text: ReturnType<typeof vi.fn>;

10+

} {

11+

const encoded = new TextEncoder().encode(body);

12+

let read = false;

13+

const cancel = vi.fn(async () => undefined);

14+

const releaseLock = vi.fn();

15+

const text = vi.fn(async () => {

16+

throw new Error("response.text() should not be called");

17+

});

18+

const response = {

19+

ok: false,

20+

status,

21+

headers: new Headers(),

22+

body: {

23+

getReader: () => ({

24+

read: async () => {

25+

if (read) {

26+

return { done: true, value: undefined };

27+

}

28+

read = true;

29+

return { done: false, value: encoded };

30+

},

31+

cancel,

32+

releaseLock,

33+

}),

34+

},

35+

text,

36+

} as unknown as Response;

37+
38+

return { response, cancel, releaseLock, text };

39+

}

40+
541

describe("chutes plugin OAuth", () => {

642

it("rejects unsafe token lifetimes before storing credentials", async () => {

743

const fetchFn = vi.fn(async (input: RequestInfo | URL) => {

@@ -33,4 +69,47 @@ describe("chutes plugin OAuth", () => {

3369

}),

3470

).rejects.toThrow("Chutes token exchange returned invalid expires_in");

3571

});

72+
73+

it("bounds token exchange error bodies without requiring response.text()", async () => {

74+

const errorResponse = boundedErrorResponse(

75+

`${"chutes token unavailable ".repeat(1024)}tail-marker`,

76+

502,

77+

);

78+

const fetchFn = vi.fn(async (input: RequestInfo | URL) => {

79+

const url =

80+

typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;

81+

if (url === "https://api.chutes.ai/idp/token") {

82+

return errorResponse.response;

83+

}

84+

return new Response("not found", { status: 404 });

85+

});

86+
87+

let error: unknown;

88+

try {

89+

await loginChutes({

90+

app: {

91+

clientId: "cid_test",

92+

redirectUri: "http://127.0.0.1:1456/oauth-callback",

93+

scopes: ["openid"],

94+

},

95+

manual: true,

96+

createState: () => "state_test",

97+

onAuth: vi.fn(async () => {}),

98+

onPrompt: vi.fn(

99+

async () => "http://127.0.0.1:1456/oauth-callback?code=code_test&state=state_test",

100+

),

101+

fetchFn,

102+

});

103+

} catch (caught) {

104+

error = caught;

105+

}

106+
107+

expect(error).toBeInstanceOf(Error);

108+

const message = (error as Error).message;

109+

expect(message).toContain("Chutes token exchange failed: chutes token unavailable");

110+

expect(message).not.toContain("tail-marker");

111+

expect(errorResponse.text).not.toHaveBeenCalled();

112+

expect(errorResponse.cancel).toHaveBeenCalledTimes(1);

113+

expect(errorResponse.releaseLock).toHaveBeenCalledTimes(1);

114+

});

36115

});