Repository navigation
fix(query-parser): stop treating dotted numbers as file-path filters - #870
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughFilename constraint validation now rejects numeric-leading extensions. Parser tests confirm that dotted numbers remain search text while valid filenames still produce ChangesFilename constraint validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The parser now keeps dotted numeric input as search text while retaining valid filename filters, with no actionable merge risk identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Confidence Score: 4/5The implementation appears safe to merge, with a non-blocking gap in the regression test’s assertions. The parser currently preserves dotted-number tokens as search text and the predicate change matches its documented contract; only the test’s ability to detect future token-loss regressions is incomplete. Files Needing Attention: crates/fff-query-parser/src/parser.rs
|
| Filename | Overview |
|---|---|
| crates/fff-query-parser/src/constraints.rs | Narrows implicit filename detection to alphabetic-led extensions, consistently implementing the documented rule. |
| crates/fff-query-parser/src/parser.rs | Adds relevant regression cases, but verifies only constraint removal rather than preservation of the complete search text. |
Reviews (1): Last reviewed commit: "fix(query-parser): stop treating dotted ..." | Re-trigger Greptile
| assert!( | ||
| result.constraints.is_empty(), | ||
| "{label}: {query:?} must stay search text, got {:?}", | ||
| result.constraints | ||
| ); |
There was a problem hiding this comment.
This regression test only checks that dotted numbers produce no constraints. It does not verify that the complete token remains in the searchable text, so an implementation that accidentally discards the token would still pass and leave the reported search failure uncovered. Please also assert the resulting grep_text() or fuzzy-query contents for each case.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
The defect
Grepping for a version number or an IP address scopes the search to a file path
that does not exist, so the query returns nothing of its own and falls back to
unrelated results:
Constraint::is_filename_constraint_tokendecides which bare tokens become aFilePathscope. Its own doc comment states the rule that keeps version-liketokens out:
The first clause is never implemented — only the "alphanumeric" part is:
v2.0-> extension"0",192.168.1.1->"1",3.11->"11". Allnon-empty, all alphanumeric, so all three become
FilePathconstraints.test_file_picker_version_number_not_filenamewas written for exactly this("v2.0 extension starts with digit -> not a filename constraint"), but it builds
its parser from
FileSearchConfig, whereenable_filename_constraintisfalseby the trait default. The token never reaches the check, so the test passes
without exercising it — and it still passes both before and after this change.
Why it matters
enable_filename_constraintis on unconditionally inAiGrepConfig, the configfff-mcp's grep tool parses every query with, and opt-in for:FFGrepviagrep.enable_filename_constraint. Both go throughprefilter_with_filepath_retry,so a query scoped to a path no file has matches nothing and is then re-run
repo-wide with the scope dropped — the caller gets "0 exact matches" followed by
hits that have nothing to do with the number it searched for.
The fix
Implement the documented first-character rule.
starts_withon acharpredicate is
falsefor an empty string, so it subsumes theis_emptycheck itreplaces.
Verification (Windows, default features)
RUSTUP_TOOLCHAINwas pinned to1.98.0-x86_64-pc-windows-msvcbecauserust-toolchain.toml'sstablechannel could not update on this machine.New test
test_dotted_numbers_are_not_filename_constraintsruns the sameassertions through
AiGrepConfigand through a config withenable_filename_constraintenabled, mirroring the Neovim opt-in.Before,
cargo test -p fff-query-parser --lib -- test_dotted_numbers:After:
The same test pins what must not change, in both configs — these two assertions
pass before and after, so the rule only rejects digit-led extensions and does not
narrow real filenames:
schema.rs usersstill yieldsFilePath("schema.rs").libswscale/input.c avframestill yieldsFilePath("libswscale/input.c").test_file_picker_bare_filename_constraint,test_file_picker_path_prefixed_filename_constraint,test_file_picker_only_one_filepath_constraintandtest_file_picker_version_number_not_filenameare unchanged and still pass.cargo test -p fff-query-parser— 90 lib + 3 doc tests passed, 0 failed(baseline on unmodified upstream: 89 lib + 3 doc, 0 failed).
cargo test -p fff-search --lib— 162 passed, 0 failed.cargo test -p fff-search --test grep_integration— 68 passed, 0 failed.cargo test -p fff-mcp— 22 + 1 passed, 0 failed.cargo fmt --all -- --check— clean.cargo clippy -p fff-query-parser --all-targets— no warnings, same asunmodified upstream (delta 0).
🤖 Generated with Claude Code
Summary by CodeRabbit