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

推荐订阅源

Vercel News
Vercel News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
有赞技术团队
有赞技术团队
罗磊的独立博客
博客园 - 叶小钗
Jina AI
Jina AI
博客园 - 司徒正美
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Microsoft Security Blog
Microsoft Security Blog
大猫的无限游戏
大猫的无限游戏
量子位
MyScale Blog
MyScale Blog
V
Visual Studio Blog
博客园 - 聂微东
The Cloudflare Blog
Engineering at Meta
Engineering at Meta
小众软件
小众软件
宝玉的分享
宝玉的分享

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(ci): cap dependency guard error bodies · openclaw/ope...
vincentkoc · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -6,6 +6,7 @@ export const dependencyChangeMarker = "<!-- openclaw:dependency-guard -->";

66

export const dependencyGraphGuardMarker = "<!-- openclaw:dependency-graph-guard -->";

77

export const dependencyChangedLabel = "dependencies-changed";

88

export const allowDependenciesCommand = "/allow-dependencies-change";

9+

export const GITHUB_ERROR_BODY_MAX_BYTES = 64 * 1024;

910
1011

const maxListedFiles = 25;

1112

const securityTeamSlug = process.env.OPENCLAW_SECURITY_TEAM_SLUG ?? "openclaw-secops";

@@ -312,7 +313,55 @@ export function renderBlockedDependencyComment({

312313

].join("\n");

313314

}

314315
315-

function githubApi(token) {

316+

function githubErrorBodyTooLarge(maxBytes) {

317+

return new Error(`GitHub error response body exceeded ${maxBytes} bytes`);

318+

}

319+
320+

export async function readBoundedGitHubErrorText(response, maxBytes = GITHUB_ERROR_BODY_MAX_BYTES) {

321+

const contentLength = Number(response.headers.get("content-length") ?? "");

322+

if (Number.isSafeInteger(contentLength) && contentLength > maxBytes) {

323+

await response.body?.cancel().catch(() => undefined);

324+

throw githubErrorBodyTooLarge(maxBytes);

325+

}

326+

if (!response.body) {

327+

return "";

328+

}

329+
330+

const reader = response.body.getReader();

331+

const decoder = new TextDecoder();

332+

const chunks = [];

333+

let totalBytes = 0;

334+

let canceled = false;

335+
336+

try {

337+

for (;;) {

338+

const { done, value } = await reader.read();

339+

if (done) {

340+

const tail = decoder.decode();

341+

if (tail) {

342+

chunks.push(tail);

343+

}

344+

break;

345+

}

346+
347+

totalBytes += value.byteLength;

348+

if (totalBytes > maxBytes) {

349+

canceled = true;

350+

await reader.cancel().catch(() => undefined);

351+

throw githubErrorBodyTooLarge(maxBytes);

352+

}

353+

chunks.push(decoder.decode(value, { stream: true }));

354+

}

355+

} finally {

356+

if (!canceled) {

357+

reader.releaseLock();

358+

}

359+

}

360+
361+

return chunks.join("");

362+

}

363+
364+

export function githubApi(token) {

316365

const baseHeaders = {

317366

accept: "application/vnd.github+json",

318367

authorization: `Bearer ${token}`,

@@ -328,9 +377,13 @@ function githubApi(token) {

328377

return null;

329378

}

330379

if (!response.ok) {

331-

const error = new Error(

332-

`${response.status} ${response.statusText}: ${await response.text()}`,

333-

);

380+

let errorText;

381+

try {

382+

errorText = await readBoundedGitHubErrorText(response);

383+

} catch (bodyError) {

384+

errorText = bodyError instanceof Error ? bodyError.message : String(bodyError);

385+

}

386+

const error = new Error(`${response.status} ${response.statusText}: ${errorText}`);

334387

error.status = response.status;

335388

throw error;

336389

}

Original file line numberDiff line numberDiff line change

@@ -1,14 +1,17 @@

11

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

22

import {

3+

GITHUB_ERROR_BODY_MAX_BYTES,

34

dependencyGuardCommentHeadSha,

45

dependencyFieldChanges,

56

dependencyOverrideExpectedSha,

67

findDependencyOverrideCommand,

78

findDependencyOverrideCommandAsync,

9+

githubApi,

810

isDependencyGuardAuthorizedForHead,

911

isDependencyFile,

1012

isDependencyManifest,

1113

isPackageLockfile,

14+

readBoundedGitHubErrorText,

1215

renderAuthorizedDependencyComment,

1316

renderBlockedDependencyComment,

1417

renderClearedDependencyGuardComment,

@@ -269,4 +272,54 @@ describe("dependency guard script", () => {

269272

expect(sanitizeDisplayValue("abc\u0000def")).toBe("abc?def");

270273

expect(sanitizeDisplayValue("x".repeat(300))).toHaveLength(240);

271274

});

275+
276+

it("bounds GitHub error bodies by content-length", async () => {

277+

const response = new Response("ignored", {

278+

headers: { "content-length": String(GITHUB_ERROR_BODY_MAX_BYTES + 1) },

279+

});

280+
281+

await expect(readBoundedGitHubErrorText(response)).rejects.toThrow(

282+

`GitHub error response body exceeded ${GITHUB_ERROR_BODY_MAX_BYTES} bytes`,

283+

);

284+

});

285+
286+

it("bounds GitHub error bodies by streamed bytes", async () => {

287+

const response = new Response(

288+

new ReadableStream({

289+

start(controller) {

290+

controller.enqueue(new Uint8Array(GITHUB_ERROR_BODY_MAX_BYTES + 1));

291+

controller.close();

292+

},

293+

}),

294+

);

295+
296+

await expect(readBoundedGitHubErrorText(response)).rejects.toThrow(

297+

`GitHub error response body exceeded ${GITHUB_ERROR_BODY_MAX_BYTES} bytes`,

298+

);

299+

});

300+
301+

it("preserves GitHub status when an error body exceeds the cap", async () => {

302+

const originalFetch = globalThis.fetch;

303+

globalThis.fetch = (() =>

304+

Promise.resolve(

305+

new Response(

306+

new ReadableStream({

307+

start(controller) {

308+

controller.enqueue(new Uint8Array(GITHUB_ERROR_BODY_MAX_BYTES + 1));

309+

controller.close();

310+

},

311+

}),

312+

{ status: 403, statusText: "Forbidden" },

313+

),

314+

)) as typeof fetch;

315+
316+

try {

317+

await expect(githubApi("token").request("/repos/openclaw/openclaw")).rejects.toMatchObject({

318+

message: `403 Forbidden: GitHub error response body exceeded ${GITHUB_ERROR_BODY_MAX_BYTES} bytes`,

319+

status: 403,

320+

});

321+

} finally {

322+

globalThis.fetch = originalFetch;

323+

}

324+

});

272325

});