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

推荐订阅源

M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
GbyAI
GbyAI
S
SegmentFault 最新的问题
量子位
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
aimingoo的专栏
aimingoo的专栏
V
Visual Studio Blog
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
J
Java Code Geeks
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
IT之家
IT之家
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
雷峰网
雷峰网

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

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

9494

- Exa: report malformed search API JSON with a provider-owned error instead of leaking raw parser failures.

9595

- Memory host SDK: report malformed remote JSON with caller-scoped errors for POST and batch file upload responses instead of leaking raw parser failures.

9696

- Media providers: report malformed operation-poll and audio-transcription JSON with provider-owned errors instead of leaking raw parser failures.

97+

- MiniMax, Gemini, Kimi, and Ollama web search: report malformed API JSON with provider-owned errors instead of leaking raw parser failures.

9798

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

9899

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

99100

- 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

@@ -1,6 +1,7 @@

11

import {

22

createProviderHttpError,

33

formatProviderHttpErrorMessage,

4+

readProviderJsonResponse,

45

} from "openclaw/plugin-sdk/provider-http";

56

import {

67

buildSearchCacheKey,

@@ -196,13 +197,7 @@ async function runGeminiSearch(params: {

196197

throw new Error(error.message.replace(/key=[^&\s]+/giu, "key=***"));

197198

}

198199
199-

let data: GeminiGroundingResponse;

200-

try {

201-

data = (await res.json()) as GeminiGroundingResponse;

202-

} catch (error) {

203-

const safeError = String(error).replace(/key=[^&\s]+/giu, "key=***");

204-

throw new Error(`Gemini API returned invalid JSON: ${safeError}`, { cause: error });

205-

}

200+

const data = await readProviderJsonResponse<GeminiGroundingResponse>(res, "Gemini API error");

206201
207202

if (data.error) {

208203

const rawMessage = data.error.message || data.error.status || "unknown";

Original file line numberDiff line numberDiff line change

@@ -166,6 +166,34 @@ describe("google web search provider", () => {

166166

);

167167

});

168168
169+

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

170+

vi.stubGlobal(

171+

"fetch",

172+

withFetchPreconnect(vi.fn(() => Promise.resolve(new Response("{ nope")))),

173+

);

174+

const provider = createGeminiWebSearchProvider();

175+

const tool = provider.createTool({

176+

config: {

177+

plugins: {

178+

entries: {

179+

google: {

180+

config: {

181+

webSearch: {

182+

apiKey: "AIza-plugin-test",

183+

},

184+

},

185+

},

186+

},

187+

},

188+

},

189+

searchConfig: { provider: "gemini" },

190+

});

191+
192+

await expect(tool?.execute({ query: "OpenClaw docs" })).rejects.toThrow(

193+

"Gemini API error: malformed JSON response",

194+

);

195+

});

196+
169197

it("passes provider execution abort signals into the Gemini fetch", async () => {

170198

const mockFetch = installGeminiFetch();

171199

const controller = new AbortController();

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,7 @@

11

import {

22

createProviderHttpError,

33

formatProviderHttpErrorMessage,

4+

readProviderJsonResponse,

45

} from "openclaw/plugin-sdk/provider-http";

56

import {

67

DEFAULT_SEARCH_COUNT,

@@ -145,7 +146,10 @@ async function runMiniMaxSearch(params: {

145146

throw await createProviderHttpError(res, "MiniMax Search API error");

146147

}

147148
148-

const data = (await res.json()) as MiniMaxSearchResponse;

149+

const data = await readProviderJsonResponse<MiniMaxSearchResponse>(

150+

res,

151+

"MiniMax Search API error",

152+

);

149153
150154

if (data.base_resp?.status_code && data.base_resp.status_code !== 0) {

151155

throw new Error(

@@ -261,4 +265,5 @@ export const __testing = {

261265

resolveMiniMaxApiKey,

262266

resolveMiniMaxEndpoint,

263267

resolveMiniMaxRegion,

268+

readMiniMaxSearchJsonResponse: readProviderJsonResponse<MiniMaxSearchResponse>,

264269

} as const;

Original file line numberDiff line numberDiff line change

@@ -7,6 +7,7 @@ const {

77

resolveMiniMaxApiKey,

88

resolveMiniMaxEndpoint,

99

resolveMiniMaxRegion,

10+

readMiniMaxSearchJsonResponse,

1011

} = minimaxWebSearchTesting;

1112
1213

function restoreEnvValue(key: string, value: string | undefined) {

@@ -167,4 +168,10 @@ describe("minimax web search provider", () => {

167168

expect(MINIMAX_SEARCH_ENDPOINT_CN).toBe("https://api.minimaxi.com/v1/coding_plan/search");

168169

});

169170

});

171+
172+

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

173+

await expect(

174+

readMiniMaxSearchJsonResponse(new Response("{ nope"), "MiniMax Search API error"),

175+

).rejects.toThrow("MiniMax Search API error: malformed JSON response");

176+

});

170177

});

Original file line numberDiff line numberDiff line change

@@ -1,4 +1,7 @@

1-

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

1+

import {

2+

createProviderHttpError,

3+

readProviderJsonResponse,

4+

} from "openclaw/plugin-sdk/provider-http";

25

import type { OpenClawConfig } from "openclaw/plugin-sdk/provider-onboard";

36

import {

47

buildSearchCacheKey,

@@ -216,7 +219,7 @@ async function runKimiSearch(params: {

216219

throw await createProviderHttpError(res, "Kimi API error");

217220

}

218221
219-

const data = (await res.json()) as KimiSearchResponse;

222+

const data = await readProviderJsonResponse<KimiSearchResponse>(res, "Kimi API error");

220223

if (hasKimiSearchResults(data)) {

221224

hasGroundingEvidence = true;

222225

}

Original file line numberDiff line numberDiff line change

@@ -158,6 +158,17 @@ describe("kimi web search provider", () => {

158158

});

159159

});

160160
161+

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

162+

const fetchMock = vi.fn().mockResolvedValue(new Response("{ nope"));

163+

vi.stubGlobal("fetch", fetchMock);

164+
165+

await withEnvAsync({ KIMI_API_KEY: "kimi-test-key" }, async () => {

166+

await expect(executeKimiSearch("kimi malformed response")).rejects.toThrow(

167+

"Kimi API error: malformed JSON response",

168+

);

169+

});

170+

});

171+
161172

it("accepts final responses backed by Kimi web search tool replay", async () => {

162173

const toolArguments = JSON.stringify({

163174

query: "OpenClaw GitHub repository",

Original file line numberDiff line numberDiff line change

@@ -391,6 +391,20 @@ describe("ollama web search provider", () => {

391391

);

392392

});

393393
394+

it("reports malformed Ollama web search JSON with a stable provider error", async () => {

395+

fetchWithSsrFGuardMock.mockResolvedValueOnce({

396+

response: new Response("{ nope", { status: 200 }),

397+

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

398+

});

399+
400+

await expect(

401+

runOllamaWebSearch({

402+

config: createOllamaConfig(),

403+

query: "openclaw",

404+

}),

405+

).rejects.toThrow("Ollama web search returned malformed JSON");

406+

});

407+
394408

it("warns when Ollama is not reachable during setup without cancelling", async () => {

395409

fetchWithSsrFGuardMock.mockRejectedValueOnce(new Error("connect failed"));

396410
Original file line numberDiff line numberDiff line change

@@ -65,6 +65,14 @@ type OllamaWebSearchAttempt = {

6565

apiKey?: string;

6666

};

6767
68+

async function readOllamaWebSearchResponse(response: Response): Promise<OllamaWebSearchResponse> {

69+

try {

70+

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

71+

} catch (cause) {

72+

throw new Error("Ollama web search returned malformed JSON", { cause });

73+

}

74+

}

75+
6876

function isOllamaCloudBaseUrl(baseUrl: string): boolean {

6977

try {

7078

const parsed = new URL(baseUrl);

@@ -211,7 +219,7 @@ export async function runOllamaWebSearch(params: {

211219

}

212220

throw new Error(message);

213221

}

214-

payload = (await response.json()) as OllamaWebSearchResponse;

222+

payload = await readOllamaWebSearchResponse(response);

215223

break;

216224

} catch (error) {

217225

if (error instanceof Error) {

@@ -336,5 +344,6 @@ export const __testing = {

336344

resolveOllamaWebSearchApiKey,

337345

resolveOllamaWebSearchBaseUrl,

338346

isOllamaCloudBaseUrl,

347+

readOllamaWebSearchResponse,

339348

warnOllamaWebSearchPrereqs,

340349

};