GitNexus/gitnexus/src/core
azizur100389 decb838bb9 fix(search): guard against undefined bm25Results when FTS unavailable (#1489) (#1540)
* fix(search): guard against undefined bm25Results when FTS unavailable (#1489)

When the FTS extension is unavailable in the MCP process,
searchFTSFromLbug can return an unexpected shape or throw,
leaving bm25Results undefined. The for-loop then crashes with
"bm25Results is not iterable".

- mergeWithRRF: default both inputs via ?? [] so undefined
  never reaches the iteration loops
- hybridSearch: wrap searchFTSFromLbug in try/catch and fall
  back to semantic-only search instead of crashing
- local-backend query handler: guard bm25SearchResult?.results
  and semanticResults with ?? []
- bm25Search: wrap the dynamic import in try/catch for
  sandboxed MCP contexts; guard ftsResponse?.results

Adds 6 regression tests covering undefined inputs and FTS
failure fallback.

Fixes #1489

* fix(search): address review findings on #1489 crash guards

- Guard ftsResponse.results with ?? [] in hybridSearch (Finding 1)
- Add logger.warn on bm25-index.js import failure (Finding 3)
- Add unit test for callTool query FTS throw path (Finding 2)

---------

Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
2026-05-13 12:30:21 +01:00
..
augmentation fix(augment): add CONTAINS fallback when FTS indexes unavailable (#1476) 2026-05-11 16:39:10 +01:00
embeddings feat(embeddings): forward dimensions param in HTTP embedding requests (#1498) 2026-05-11 13:56:10 +01:00
graph feat(python): scope-based call resolution + registry-primary flip + perf + generalization (RFC #909 Ring 3) (#980) 2026-04-21 15:50:00 +01:00
group fix(group): detect httpx async consumers (#1408) 2026-05-11 13:13:49 +01:00
incremental feat(analyze): incremental indexing (parse cache + DB writeback + scope-res short-circuit) (#1479) 2026-05-12 13:14:56 +01:00
ingestion feat(php): migrate PHP to scope-based resolution model (#938) [supersedes #1124] (#1497) 2026-05-12 16:56:31 +01:00
lbug fix(lbug): drain checkpoint result before close (#1506) 2026-05-12 14:03:45 +01:00
platform fix: add platform-aware semantic fallback (#1150) 2026-04-28 12:21:25 +01:00
search fix(search): guard against undefined bm25Results when FTS unavailable (#1489) (#1540) 2026-05-13 12:30:21 +01:00
tree-sitter fix(windows): 32767-char tree-sitter crash + VECTOR extension SIGSEGV (#1433) 2026-05-10 16:00:36 +01:00
wiki fix(wiki): sanitize generated mermaid diagrams (#1539) 2026-05-13 11:53:09 +01:00
embedding-mode.ts feat: add optional limit arg to --embeddings flag (closes #382) (#1375) 2026-05-06 16:31:28 +01:00
git-staleness.ts perf(mcp): parallelize staleness checks in list_repos (#1416) 2026-05-08 10:36:20 +01:00
logger.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
run-analyze.ts feat(analyze): incremental indexing (parse cache + DB writeback + scope-res short-circuit) (#1479) 2026-05-12 13:14:56 +01:00