#23747: fix(memory): widen null-byte collection repair to catch ENOENT errors
size: S
trusted-contributor
Closes #23746
## Problem
The existing `tryRepairNullByteCollections` repair logic only triggers on `ENOTDIR` errors. Bun v1.3.x has a bug where it appends a null byte (`\u0000`) to file paths read from SQLite ([tobi/qmd#111](https://github.com/tobi/qmd/issues/111)). This can produce `ENOENT` errors instead of `ENOTDIR`, causing the repair to never fire.
## Fix
Widen `shouldRepairNullByteCollectionError` to also match:
- `enoent`
- `no such file`
when `NUL_MARKER_RE` is present in the error message.
## Testing
- Added test: `rebuilds managed collections once when qmd update fails with null-byte ENOENT`
- Parallel to existing `ENOTDIR` test, uses `ENOENT: no such file or directory` with `\u0000` marker
- All 45 tests in `qmd-manager.test.ts` pass
## Changes
- `src/memory/qmd-manager.ts`: 2 lines added to condition
- `src/memory/qmd-manager.test.ts`: 1 new test case (55 lines)
Most Similar PRs
#12939: fix(memory): strip null bytes from workspace paths causing ENOTDIR
by omair445 · 2026-02-09
65.5%
#21868: fix: qmd search/vsearch silently return empty with multiple -c coll...
by jacksclaw · 2026-02-20
62.6%
#22937: fix: remove legacy unsuffixed QMD collections on upgrade
by sud0n1m-ziggy · 2026-02-21
61.9%
#16968: fix(qmd): per-collection search to prevent large collections drowni...
by ProgramCaiCai · 2026-02-15
61.4%
#20966: fix(memory/qmd): migrate orphaned unscoped collections on upgrade
by marcodelpin · 2026-02-19
61.1%
#19100: Fix memory vector store dimension mismatch by resetting index
by Clawborn · 2026-02-17
60.9%
#9624: fix(memory): resolve QMD search returning empty results [AI-assisted]
by kowshik24 · 2026-02-05
60.5%
#16917: fix(memory): close stale SQLite connection after qmd update
by zerone0x · 2026-02-15
58.3%
#20125: fix(doctor): skip memorySearch provider check when using QMD backend
by brandonwise · 2026-02-18
57.3%
#23480: fix(test): use path.join for cross-platform XDG path assertions in ...
by hydro13 · 2026-02-22
57.2%