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

推荐订阅源

F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
V
Visual Studio Blog
罗磊的独立博客
爱范儿
爱范儿
J
Java Code Geeks
博客园 - 司徒正美
N
Netflix TechBlog - Medium
Microsoft Security Blog
Microsoft Security Blog
美团技术团队
小众软件
小众软件
Google DeepMind News
Google DeepMind News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX
博客园 - 聂微东
云风的 BLOG
云风的 BLOG
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Jina AI
Jina AI
Y
Y Combinator Blog
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Martin Fowler
Martin Fowler
Vercel News
Vercel News

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: suppress raw JSON parse errors from leaking to Disco...
singleGangho · 2026-04-29 · via Recent Commits to openclaw:main

@@ -1,12 +1,14 @@

11

import type { AssistantMessage } from "@mariozechner/pi-ai";

22

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

3+

import { MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "../shared/assistant-error-format.js";

34

import {

45

BILLING_ERROR_USER_MESSAGE,

56

formatBillingErrorMessage,

67

formatAssistantErrorText,

78

getApiErrorPayloadFingerprint,

89

formatRawAssistantErrorForUi,

910

isRawApiErrorPayload,

11+

sanitizeUserFacingText,

1012

} from "./pi-embedded-helpers.js";

1113

import { makeAssistantMessageFixture } from "./test-helpers/assistant-message-fixtures.js";

1214

@@ -349,6 +351,34 @@ describe("formatAssistantErrorText", () => {

349351

"LLM request failed: provider returned an invalid streaming response. Please try again.",

350352

);

351353

});

354+355+

it("sanitizes transport-classified malformed streaming fragments (#59076)", () => {

356+

const msg = makeAssistantError(MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE);

357+

expect(formatAssistantErrorText(msg)).toBe(

358+

"LLM streaming response contained a malformed fragment. Please try again.",

359+

);

360+

});

361+362+

it("does not broadly rewrite non-streaming 'Unexpected token' JSON parse errors", () => {

363+

const msg = makeAssistantError("Unexpected token < in JSON at position 0");

364+

expect(formatAssistantErrorText(msg)).toBe("Unexpected token < in JSON at position 0");

365+

});

366+367+

it("does not rewrite non-streaming provider JSON request-validation diagnostics", () => {

368+

const msg = makeAssistantError("Expected value in JSON at position 12 for messages.0.content");

369+

expect(formatAssistantErrorText(msg)).toBe(

370+

"Expected value in JSON at position 12 for messages.0.content",

371+

);

372+

});

373+374+

it("keeps provider request-validation JSON diagnostics actionable", () => {

375+

const msg = makeAssistantError(

376+

'{"type":"error","error":{"type":"invalid_request_error","message":"Expected value in JSON at position 12 for messages.0.content"}}',

377+

);

378+

expect(formatAssistantErrorText(msg)).toBe(

379+

"LLM request rejected: Expected value in JSON at position 12 for messages.0.content",

380+

);

381+

});

352382

});

353383354384

describe("formatRawAssistantErrorForUi", () => {

@@ -424,3 +454,21 @@ describe("raw API error payload helpers", () => {

424454

);

425455

});

426456

});

457+458+

describe("sanitizeUserFacingText — streaming JSON parse error (#59076)", () => {

459+

it("rewrites transport-classified malformed streaming fragments in error context", () => {

460+

const result = sanitizeUserFacingText(MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, {

461+

errorContext: true,

462+

});

463+

expect(result).toBe("LLM streaming response contained a malformed fragment. Please try again.");

464+

});

465+466+

it("does not rewrite JSON parse error when not in error context", () => {

467+

// When not in error context, the text could be legitimate assistant content

468+

// mentioning JSON errors. Don't rewrite.

469+

const text =

470+

"Expected ',' or '}' after property value in JSON at position 334 (line 1 column 335)";

471+

const result = sanitizeUserFacingText(text, { errorContext: false });

472+

expect(result).toBe(text);

473+

});

474+

});