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

推荐订阅源

The Cloudflare Blog
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tailwind CSS Blog
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
博客园 - 司徒正美
V
Visual Studio Blog
G
Google Developers Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
博客园_首页
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
D
Docker
Vercel News
Vercel News
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
爱范儿
爱范儿
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏

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(googlechat): wrap malformed api json · openclaw/openc...
vincentkoc · 2026-05-15 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -86,6 +86,7 @@ Docs: https://docs.openclaw.ai

8686

- xAI tools: report malformed web search, X search, and code execution JSON with provider-owned errors instead of leaking raw parser failures.

8787

- Nextcloud Talk: report malformed room-info and bot-admin JSON with channel-owned errors instead of leaking raw parser failures.

8888

- Microsoft Teams: report malformed Graph and delegated OAuth JSON with channel-owned errors instead of leaking raw parser failures.

89+

- Google Chat: report malformed Chat API and certificate JSON with channel-owned errors instead of leaking raw parser failures.

8990

- Twilio voice-call: report malformed successful API JSON responses with provider-owned errors instead of leaking raw parser failures.

9091

- Voice-call provider APIs: report malformed successful guarded JSON responses with provider-prefixed errors instead of leaking raw parser failures.

9192

- Realtime transcription: report malformed provider websocket JSON frames with owned parser errors instead of leaking raw `SyntaxError` objects.

Original file line numberDiff line numberDiff line change

@@ -9,6 +9,14 @@ import type { GoogleChatReaction } from "./types.js";

99

const CHAT_API_BASE = "https://chat.googleapis.com/v1";

1010

const CHAT_UPLOAD_BASE = "https://chat.googleapis.com/upload/v1";

1111
12+

async function readGoogleChatJsonResponse<T>(response: Response, label: string): Promise<T> {

13+

try {

14+

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

15+

} catch (cause) {

16+

throw new Error(`${label}: malformed JSON response`, { cause });

17+

}

18+

}

19+
1220

const headersToObject = (headers?: HeadersInit): Record<string, string> =>

1321

headers instanceof Headers

1422

? Object.fromEntries(headers.entries())

@@ -71,7 +79,8 @@ async function fetchJson<T>(

7179

},

7280

},

7381

auditContext: "googlechat.api.json",

74-

handleResponse: async (response) => (await response.json()) as T,

82+

handleResponse: async (response) =>

83+

await readGoogleChatJsonResponse<T>(response, "Google Chat API request failed"),

7584

});

7685

}

7786

@@ -217,9 +226,9 @@ export async function uploadGoogleChatAttachment(params: {

217226

auditContext: "googlechat.upload",

218227

errorPrefix: "Google Chat upload",

219228

handleResponse: async (response) =>

220-

(await response.json()) as {

229+

await readGoogleChatJsonResponse<{

221230

attachmentDataRef?: { attachmentUploadToken?: string };

222-

},

231+

}>(response, "Google Chat upload failed"),

223232

});

224233

return {

225234

attachmentUploadToken: payload.attachmentDataRef?.attachmentUploadToken,

Original file line numberDiff line numberDiff line change

@@ -15,6 +15,14 @@ const ADDON_ISSUER_PATTERN = /^service-\d+@gcp-sa-gsuiteaddons\.iam\.gserviceacc

1515

const CHAT_CERTS_URL =

1616

"https://www.googleapis.com/service_accounts/v1/metadata/x509/chat@system.gserviceaccount.com";

1717
18+

async function readGoogleChatCertsResponse(response: Response): Promise<Record<string, string>> {

19+

try {

20+

return (await response.json()) as Record<string, string>;

21+

} catch (cause) {

22+

throw new Error("Google Chat cert fetch failed: malformed JSON response", { cause });

23+

}

24+

}

25+
1826

// Size-capped to prevent unbounded growth in long-running deployments (#4948)

1927

const MAX_AUTH_CACHE_SIZE = 32;

2028

type GoogleAuthModule = typeof import("google-auth-library");

@@ -122,7 +130,7 @@ async function fetchChatCerts(): Promise<Record<string, string>> {

122130

if (!response.ok) {

123131

throw new Error(`Failed to fetch Chat certs (${response.status})`);

124132

}

125-

const certs = (await response.json()) as Record<string, string>;

133+

const certs = await readGoogleChatCertsResponse(response);

126134

cachedCerts = { fetchedAt: now, certs };

127135

return certs;

128136

} finally {

Original file line numberDiff line numberDiff line change

@@ -249,6 +249,26 @@ describe("sendGoogleChatMessage", () => {

249249

const url = mockCallArg(fetchMock);

250250

expect(String(url)).not.toContain("messageReplyOption=");

251251

});

252+
253+

it("reports malformed send JSON with a stable API error", async () => {

254+

vi.stubGlobal(

255+

"fetch",

256+

vi.fn().mockResolvedValue(

257+

new Response("{ nope", {

258+

status: 200,

259+

headers: { "content-type": "application/json" },

260+

}),

261+

),

262+

);

263+
264+

await expect(

265+

sendGoogleChatMessage({

266+

account,

267+

space: "spaces/AAA",

268+

text: "hello",

269+

}),

270+

).rejects.toThrow("Google Chat API request failed: malformed JSON response");

271+

});

252272

});

253273
254274

function mockTicket(payload: Record<string, unknown>) {

@@ -406,4 +426,25 @@ describe("verifyGoogleChatRequest", () => {

406426

);

407427

expect(release).toHaveBeenCalledOnce();

408428

});

429+
430+

it("reports malformed Chat cert JSON with a stable auth error", async () => {

431+

authTesting.resetGoogleChatAuthForTests();

432+

const release = vi.fn(async () => {});

433+

mocks.fetchWithSsrFGuard.mockResolvedValueOnce({

434+

response: new Response("{ nope", {

435+

status: 200,

436+

headers: { "content-type": "application/json" },

437+

}),

438+

release,

439+

});

440+
441+

await expect(

442+

verifyGoogleChatRequest({

443+

bearer: "token",

444+

audienceType: "project-number",

445+

audience: "123456789",

446+

}),

447+

).rejects.toThrow("Google Chat cert fetch failed: malformed JSON response");

448+

expect(release).toHaveBeenCalledOnce();

449+

});

409450

});