fix(native): widen NativeRepository file filters to accept string[]#1959
Conversation
triage, and the unwired findNodesByScope/findNodeByQualifiedName/ listFunctionNodes/iterateFunctionNodes native bindings, forwarded the CLI's repeatable -f/--file array straight into rusqlite bindings typed for a single Rust String. triage silently swallowed the resulting napi-rs conversion error into an empty result at exit code 0; the others would crash the same way once wired up. Widen the five NativeDatabase bindings (Rust + TS declarations) to Option<Vec<String>>, reusing the push_file_filter() helper already shared by find_nodes_with_fan_in/fn_deps, and forward the full normalized array from NativeRepository instead of truncating to the first value. Also narrow triageData's catch to only swallow the validated-input ConfigError case so a genuine internal failure propagates instead of masquerading as "no symbols match". Impact: 24 functions changed, 46 affected
Greptile SummaryThis PR fixes a silent napi-rs type-conversion crash where
Confidence Score: 5/5Safe to merge. The change is a targeted type-widening fix with consistent application across all three repository backends, reuses a well-tested SQL helper, and is covered by new end-to-end and unit regression tests. The fix is mechanically straightforward — every affected native binding now receives an array and delegates to push_file_filter(), which already drives the multi-value LIKE clause used by other bindings since #1726/#1816. The TypeScript side uniformly uses normalizeFileFilter() before passing to napi. The catch-block narrowing is safe: ConfigError is the only validation-input failure that should produce an empty graceful result, and the new tests directly assert both the propagation and degradation paths. No cross-cutting regressions are expected. No files require special attention. The Rust changes in graph_read.rs are the most impactful, but the logic is consistent with the existing push_file_filter pattern. Important Files Changed
Reviews (1): Last reviewed commit: "fix(native): widen NativeRepository file..." | Re-trigger Greptile |
Codegraph Impact Analysis26 functions changed → 24 callers affected across 17 files
|
Summary
triage -f/-f -fsilently swallowed a fatal napi-rs type-conversion error into an empty result at exit code 0, because-f(viacollectFile) always produces astring[], butfind_nodes_for_triageincrates/codegraph-core/src/db/repository/graph_read.rswas typed for a singleString. This is the same bug class fixed forfn-impact/queryin codegraph fn-impact and query crash with fatal native error when -f/--file is passed #1726/fix: prevent fn-impact/query crash when -f/--file is passed #1816.NativeRepositorymethods with no CLI caller today (find_nodes_by_scope,find_node_by_qualified_name,list_function_nodes/iterate_function_nodes) — fixed for architectural consistency so any future CLI wiring doesn't reintroduce this crash.interfaces/implementations(also named in Same -f/--file array-vs-String native crash affects triage, interfaces, implementations, and other NativeRepository methods #1815) turned out to already be fixed as a side effect of fix: prevent fn-impact/query crash when -f/--file is passed #1816 landing, since both route throughfindMatchingNodes→findNodesWithFanIn, whose native binding was widened toVec<String>in that PR. Verified via a live repro that they no longer crash.NativeDatabasebindings (Rust + TS declarations) toOption<Vec<String>>/string[], reusing thepush_file_filter()helper already shared byfind_nodes_with_fan_in/fn_deps, and updatedNativeRepositoryto forward the full normalized array instead of truncating to the first value (previously the case forfindNodesByScope).features/triage.ts's silent catch-and-return-empty: it now only degrades gracefully for the validated-inputConfigErrorcase (invalid--kind/--role, relevant to the MCPtriagetool which doesn't pre-validate); any other failure (e.g. an internal query bug) now propagates instead of masquerading as "no symbols match" at exit 0.Test plan
npm test— full suite green (3722 passed, 30 skipped, 2 todo)npm run lint/tsc --noEmit— cleantriage -freproduces the exact reported bug (Failed to convert JavaScript value \Object ["src/math.js"]` into rust type `String`swallowed into{"items":[],...}at exit 0); restored the fix, rebuilt, confirmedtriage -fand repeated-f -f` return correct non-empty, correctly-scoped resultsCODEGRAPH_ENGINE=wasmon multi-filetriage -f -f— identical items/scores (dual-engine parity)tests/integration/cli.test.ts(triage -f/-f -fend-to-end via the real CLI binary, plus smoke tests forinterfaces -f/implementations -f) andtests/integration/triage.test.ts(ConfigError-only catch behavior)Fixes #1815
Stacked on #1958 (base branch
fix/issue-1813-import-type-x-inline-per-specifier-modifier) — only the graph_read.rs/repository/triage/test diff is this issue's change.