#15307: fix(memory): handle mixed/no-results QMD query output
stale
size: S
Cluster:
QMD Memory Management Fixes
## Summary\n- normalize QMD stdout/stderr by stripping ANSI CSI/OSC sequences before parsing\n- extract balanced JSON array payloads from mixed output (progress + payload)\n- treat `No results found` markers as an empty result set instead of parse failures\n- add parser-focused unit tests for mixed output, no-results markers, and invalid payload paths\n\n## Verification\n- `pnpm exec oxlint src/memory/qmd-query-parser.ts src/memory/qmd-query-parser.test.ts`\n- `pnpm exec tsc -p tsconfig.json --noEmit`\n- `pnpm exec vitest run src/memory/qmd-query-parser.test.ts src/memory/qmd-manager.test.ts --reporter=dot`
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR hardens QMD query parsing by normalizing CLI output (stripping ANSI CSI/OSC sequences and CRs), scanning mixed stdout/stderr for a balanced JSON array payload, and treating known “No results found …” markers as an empty result set instead of a parsing failure. It also adds unit tests covering plain JSON, mixed progress+payload output, no-results markers (stdout/stderr), and the error path when no JSON payload is present.
In the codebase, `QmdMemoryManager.search()` shells out to the `qmd` CLI and calls `parseQmdQueryJson(stdout, stderr)` to turn that output into structured results; this change makes that integration resilient to extra non-JSON output emitted by the CLI.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Changes are localized to QMD output parsing and are backed by focused unit tests for the new behaviors (mixed output, no-results markers, and error cases). The parser still throws on truly invalid output and only relaxes behavior for known benign output patterns.
- src/memory/qmd-query-parser.ts
<sub>Last reviewed commit: 229d6b6</sub>
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#11364: fix(memory/qmd): prevent cascading failure when query fails or retu...
by blazerui · 2026-02-07
86.4%
#9624: fix(memory): resolve QMD search returning empty results [AI-assisted]
by kowshik24 · 2026-02-05
84.5%
#20085: Fix QMD memory_search empty results when docid key changes
by rylena · 2026-02-18
82.4%
#21471: fix: check QMD backend before memory search config
by lbo728 · 2026-02-20
79.5%
#9149: Fix: Allow QMD backend to work without OpenAI auth
by vishaltandale00 · 2026-02-04
77.9%
#20125: fix(doctor): skip memorySearch provider check when using QMD backend
by brandonwise · 2026-02-18
77.2%
#21217: fix: memory prune command to prevent unbounded MEMORY.md growth
by theognis1002 · 2026-02-19
77.1%
#19115: fix(logging): improved redaction for config objects and unquoted keys
by Clawborn · 2026-02-17
76.4%
#9381: Fix: Allow QMD CLI memory search when scope is restrictive
by vishaltandale00 · 2026-02-05
76.4%
#12939: fix(memory): strip null bytes from workspace paths causing ENOTDIR
by omair445 · 2026-02-09
76.3%