Skip to content

Commit 6eb1289

Browse files
miorbnliclaude
andcommitted
fix(memory-core): keep qmd mcporter cause generic (no raw stdout leak via formatErrorMessage)
formatErrorMessage walks the .cause chain into the user-visible path. Keeping the JSON.parse SyntaxError on .cause leaked its embedded raw stdout snippet through formatErrorMessage even with a generic message. Give the cause a generic message too; the raw snippet no longer reaches the user. Co-Authored-By: Claude <[email protected]>
1 parent 716f6e8 commit 6eb1289

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

extensions/memory-core/src/memory/qmd-manager.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,15 +2722,17 @@ export class QmdMemoryManager implements MemorySearchManager {
27222722
let parsedUnknown: unknown;
27232723
try {
27242724
parsedUnknown = JSON.parse(result.stdout);
2725-
} catch (err) {
2725+
} catch {
27262726
// mcporter (subprocess) can emit non-JSON stdout when output is truncated
27272727
// by maxOutputChars, a daemon warning bleeds onto stdout, or the CLI is
2728-
// killed early. Wrap the SyntaxError so callers get a typed domain error.
2729-
// The message stays generic on purpose: JSON.parse's SyntaxError message
2730-
// embeds a snippet of the raw input, which is surfaced before session
2731-
// visibility filtering and could leak sensitive content. The original
2732-
// error is preserved as `cause` for developer diagnostics only.
2733-
throw new Error("qmd mcporter returned non-JSON stdout", { cause: err });
2728+
// killed early. Wrap the failure so callers get a typed domain error.
2729+
// The thrown Error and its cause both carry generic messages on purpose:
2730+
// errors.ts formatErrorMessage walks the .cause chain into the user-visible
2731+
// path, so the JSON.parse SyntaxError (whose message embeds a raw stdout
2732+
// snippet) must not sit on .cause, or that snippet leaks to the user.
2733+
throw new Error("qmd mcporter returned non-JSON stdout", {
2734+
cause: new Error("mcporter stdout was not valid JSON"),
2735+
});
27342736
}
27352737
const parsedRecord = asRecord(parsedUnknown);
27362738
const structuredContent = parsedRecord ? asRecord(parsedRecord.structuredContent) : null;

0 commit comments

Comments
 (0)