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

推荐订阅源

Vercel News
Vercel News
博客园 - 【当耐特】
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
G
Google Developers Blog
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
P
Proofpoint News Feed
J
Java Code Geeks
U
Unit 42
云风的 BLOG
云风的 BLOG
阮一峰的网络日志
阮一峰的网络日志
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
Docker
V
Visual Studio Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
V
V2EX
T
Tailwind CSS Blog

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(clickclack): bound api error response bodies · opencl...
vincentkoc · 2026-06-19 · via Recent Commits to openclaw:main

File tree

  • extensions/clickclack/src

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,57 @@

1+

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

2+

import { createClickClackClient } from "./http-client.js";

3+
4+

function streamedErrorResponse(body: string, limit: number) {

5+

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

6+

let readCount = 0;

7+

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

8+

const releaseLock = vi.fn();

9+

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

10+

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

11+

});

12+
13+

const response = {

14+

ok: false,

15+

status: 502,

16+

text,

17+

body: {

18+

getReader: () => ({

19+

read: async () => {

20+

if (readCount > 0) {

21+

return { done: true, value: undefined };

22+

}

23+

readCount += 1;

24+

return { done: false, value: encoded };

25+

},

26+

cancel,

27+

releaseLock,

28+

}),

29+

},

30+

} as unknown as Response;

31+
32+

return {

33+

response,

34+

cancel,

35+

releaseLock,

36+

text,

37+

expectedDetail: body.slice(0, limit),

38+

};

39+

}

40+
41+

describe("ClickClack HTTP client", () => {

42+

it("bounds error response bodies without using raw response.text()", async () => {

43+

const streamed = streamedErrorResponse("x".repeat(9000), 8 * 1024);

44+

const fetchMock = vi.fn(async () => streamed.response);

45+

const client = createClickClackClient({

46+

baseUrl: "https://clickclack.example",

47+

token: "test-token",

48+

fetch: fetchMock,

49+

});

50+
51+

await expect(client.me()).rejects.toThrow(`ClickClack 502: ${streamed.expectedDetail}`);

52+
53+

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

54+

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

55+

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

56+

});

57+

});

Original file line numberDiff line numberDiff line change

@@ -2,6 +2,7 @@

22

* Thin ClickClack REST/websocket client used by gateway, resolver, and outbound

33

* delivery code.

44

*/

5+

import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";

56

import { WebSocket } from "ws";

67

import type {

78

ClickClackChannel,

@@ -17,6 +18,8 @@ type ClientOptions = {

1718

fetch?: typeof fetch;

1819

};

1920
21+

const CLICKCLACK_ERROR_BODY_LIMIT_BYTES = 8 * 1024;

22+
2023

/**

2124

* Creates a typed client for the ClickClack API using bearer-token auth.

2225

*/

@@ -38,7 +41,8 @@ export function createClickClackClient(options: ClientOptions) {

3841

}

3942

const response = await fetcher(`${baseUrl}${path}`, { ...init, headers: requestHeaders });

4043

if (!response.ok) {

41-

throw new Error(`ClickClack ${response.status}: ${await response.text()}`);

44+

const detail = await readResponseTextLimited(response, CLICKCLACK_ERROR_BODY_LIMIT_BYTES);

45+

throw new Error(`ClickClack ${response.status}: ${detail}`);

4246

}

4347

return (await response.json()) as T;

4448

}