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

推荐订阅源

U
Unit 42
A
About on SuperTechFans
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
月光博客
月光博客
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
T
Tailwind CSS Blog
Jina AI
Jina AI
有赞技术团队
有赞技术团队
博客园_首页

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(e2e): parse secret proof json records · openclaw/open...
vincentkoc · 2026-06-20 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -190,12 +190,76 @@ function parseJsonOutput(stdout) {

190190

if (!text) {

191191

throw new Error("expected JSON output, got empty stdout");

192192

}

193-

const first = text.indexOf("{");

194-

const last = text.lastIndexOf("}");

195-

if (first < 0 || last < first) {

193+

const parsed = parseJsonObjectsFromMixedOutput(text).at(-1);

194+

if (parsed === undefined) {

196195

throw new Error(`expected JSON object output, got: ${scrub(text.slice(0, 500))}`);

197196

}

198-

return JSON.parse(text.slice(first, last + 1));

197+

return parsed;

198+

}

199+
200+

function isJsonRecordStart(text, index) {

201+

for (let cursor = index - 1; cursor >= 0; cursor -= 1) {

202+

const char = text[cursor];

203+

if (char === "\n" || char === "\r") {

204+

return true;

205+

}

206+

if (char !== " " && char !== "\t") {

207+

return false;

208+

}

209+

}

210+

return true;

211+

}

212+
213+

function parseJsonObjectsFromMixedOutput(text) {

214+

const objects = [];

215+

let start = -1;

216+

let depth = 0;

217+

let inString = false;

218+

let escaped = false;

219+
220+

for (let index = 0; index < text.length; index += 1) {

221+

const char = text[index];

222+

if (start === -1) {

223+

if (char === "{" && isJsonRecordStart(text, index)) {

224+

start = index;

225+

depth = 1;

226+

inString = false;

227+

escaped = false;

228+

}

229+

continue;

230+

}

231+
232+

if (inString) {

233+

if (escaped) {

234+

escaped = false;

235+

} else if (char === "\\") {

236+

escaped = true;

237+

} else if (char === '"') {

238+

inString = false;

239+

}

240+

continue;

241+

}

242+

if (char === '"') {

243+

inString = true;

244+

continue;

245+

}

246+

if (char === "{") {

247+

depth += 1;

248+

continue;

249+

}

250+

if (char !== "}") {

251+

continue;

252+

}

253+
254+

depth -= 1;

255+

if (depth === 0) {

256+

try {

257+

objects.push(JSON.parse(text.slice(start, index + 1)));

258+

} catch {}

259+

start = -1;

260+

}

261+

}

262+

return objects;

199263

}

200264
201265

function resolveOpenClawRunner() {

@@ -2056,6 +2120,7 @@ export {

20562120

cleanupEnv,

20572121

expectGatewayStartupFails,

20582122

gatewayCall,

2123+

parseJsonOutput,

20592124

runPtySecretsConfigurePreset,

20602125

runWithProof,

20612126

runCommand,

Original file line numberDiff line numberDiff line change

@@ -292,6 +292,20 @@ describe("secret provider integration proof harness", () => {

292292

}

293293

});

294294
295+

it("parses JSON command output without swallowing brace-heavy diagnostics", async () => {

296+

const proof = await import(`${pathToFileURL(proofScriptPath).href}?case=json-${Date.now()}`);

297+
298+

expect(

299+

proof.parseJsonOutput(

300+

[

301+

"warning: ignored diagnostic {not json}",

302+

JSON.stringify({ ok: true, nested: { value: "kept" } }, null, 2),

303+

"debug: trailing diagnostic {also ignored}",

304+

].join("\n"),

305+

),

306+

).toEqual({ ok: true, nested: { value: "kept" } });

307+

});

308+
295309

it("records optional proof omissions as skips instead of passes", async () => {

296310

const proof = await import(`${pathToFileURL(proofScriptPath).href}?case=skip-${Date.now()}`);

297311

const log = vi.spyOn(console, "log").mockImplementation(() => {});