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

推荐订阅源

Jina AI
Jina AI
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
J
Java Code Geeks
博客园 - 聂微东
B
Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
腾讯CDC
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Azure Blog
Microsoft Azure Blog
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
美团技术团队
博客园 - Franky
Google DeepMind News
Google DeepMind News
V
V2EX
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
The Cloudflare 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(google-media): bound JSON response reads (#96920) · o...
mushuiyu886 · 2026-06-27 · via Recent Commits to openclaw:main
11

// Google tests cover media understanding provider.video plugin behavior.

2+

import { createServer, type Server } from "node:http";

23

import {

34

createRequestCaptureJsonFetch,

45

installPinnedHostnameTestHooks,

@@ -10,6 +11,49 @@ import { resolveGoogleGenerativeAiHttpRequestConfig } from "./runtime-api.js";

10111112

installPinnedHostnameTestHooks();

121314+

const LOOPBACK_RESPONSE_BYTES = 18 * 1024 * 1024;

15+16+

async function listenLoopbackServer(server: Server): Promise<number> {

17+

return await new Promise((resolve, reject) => {

18+

server.once("error", reject);

19+

server.listen(0, "127.0.0.1", () => {

20+

server.off("error", reject);

21+

const address = server.address();

22+

if (!address || typeof address === "string") {

23+

reject(new Error("expected loopback TCP address"));

24+

return;

25+

}

26+

resolve(address.port);

27+

});

28+

});

29+

}

30+31+

function createOversizedJsonServer(): { server: Server; closed: Promise<number> } {

32+

let resolveClosed: (sentBytes: number) => void = () => {};

33+

const closed = new Promise<number>((resolve) => {

34+

resolveClosed = resolve;

35+

});

36+

const server = createServer((_req, res) => {

37+

let sentBytes = 0;

38+

const chunk = Buffer.alloc(64 * 1024, 0x20);

39+

res.writeHead(200, { "content-type": "application/json" });

40+

const timer = setInterval(() => {

41+

if (sentBytes >= LOOPBACK_RESPONSE_BYTES) {

42+

clearInterval(timer);

43+

res.end();

44+

return;

45+

}

46+

sentBytes += chunk.length;

47+

res.write(chunk);

48+

}, 1);

49+

res.on("close", () => {

50+

clearInterval(timer);

51+

resolveClosed(sentBytes);

52+

});

53+

});

54+

return { server, closed };

55+

}

56+1357

describe("describeGeminiVideo", () => {

1458

it("respects case-insensitive x-goog-api-key overrides", async () => {

1559

let seenKey: string | null = null;

@@ -114,6 +158,29 @@ describe("describeGeminiVideo", () => {

114158

);

115159

});

116160161+

it("bounds oversized video JSON responses and closes the stream early", async () => {

162+

const { server, closed } = createOversizedJsonServer();

163+

const port = await listenLoopbackServer(server);

164+

const fetchFn = withFetchPreconnect(async () =>

165+

fetch(`http://127.0.0.1:${port}/google-video-json`),

166+

);

167+168+

try {

169+

await expect(

170+

describeGeminiVideo({

171+

buffer: Buffer.from("video-bytes"),

172+

fileName: "clip.mp4",

173+

apiKey: "test-key",

174+

timeoutMs: 1500,

175+

fetchFn,

176+

}),

177+

).rejects.toThrow(/JSON response exceeds 16777216 bytes/u);

178+

await expect(closed).resolves.toBeLessThan(LOOPBACK_RESPONSE_BYTES);

179+

} finally {

180+

server.close();

181+

}

182+

});

183+117184

it("rejects non-Google video base URLs before sending authenticated requests", async () => {

118185

await expect(

119186

describeGeminiVideo({