fix(edit_match): prefer literal paths over glob#133
Open
tobwen wants to merge 2 commits into
Open
Conversation
Existing paths with brackets are now treated as literal files instead of glob patterns. Falls back to glob when the path does not exist or validation fails.
Addresses Greptile P2: the Err(_) => true catch-all silently routed unknown validate_path errors to the glob handler. Return false instead so the single-file handler re-validates and surfaces the error. Dead code today (all errors use path_outside_root), zero behavior change.
56ca4d5 to
d3d29eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #132
What and why?
Existing paths with brackets are now treated as literal files instead of glob patterns. Falls back to glob when the path doesn't exist or validation fails.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Prefer literal paths over globs in
edit_matchwhen the path exists on disk, even if it contains [ ] * ? { }. Use glob only when the path doesn’t exist.should_treat_as_glob: prefer literal whenvalidate_pathresolves an existing path; onvalidate_patherrors (includingpath_outside_rootand unknown), defer to the single-file flow so errors surface correctly.Written for commit d3d29eb. Summary will update on new commits.
Greptile Summary
This PR fixes issue #132 by replacing the blunt
is_glob_patterncharacter-scan withshould_treat_as_glob, which callsvalidate_pathto check whether the path actually exists on disk before routing to the glob handler. Literal paths whose names contain[,],*,?, or{are now handled correctly as single-file edits.edit_match.rs): Newshould_treat_as_globprefers literal interpretation whenvalidate_pathresolves an existing path; falls back to glob when the candidate doesn't exist. Bothpath_outside_rootand unknownvalidate_patherrors now defer to the single-file handler (fail-safe), addressing a prior review finding.edit_test.rs): Three integration tests cover the regression (absolute bracketed path, parentheses sanity check, relative bracketed path underrestrict_to_project_root: true), giving direct coverage of the reported failure modes.Confidence Score: 5/5
Safe to merge — the change is narrowly scoped, all error arms in the new routing function are fail-safe, and the prior reviewer concern about unknown errors has been addressed.
The new
should_treat_as_globfunction correctly defers every non-glob, non-existent, and error path tohandle_single_file_edit_match, which re-validates and surfaces errors properly. Three targeted integration tests directly reproduce the reported bug.No files require special attention.
Important Files Changed
should_treat_as_globto replace the bareis_glob_patterncheck; callsvalidate_pathto confirm disk existence before routing to the glob handler. All error arms defer to the single-file handler (fail-safe).Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[handle_edit_match] --> B{should_treat_as_glob?} B -->|is_glob_pattern = false| C[handle_single_file_edit_match] B -->|is_glob_pattern = true| D[validate_path] D -->|Ok - candidate exists| C D -->|Ok - candidate NOT exists| E[handle_glob_edit_match] D -->|Err: path_outside_root| C D -->|Err: other| C%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A[handle_edit_match] --> B{should_treat_as_glob?} B -->|is_glob_pattern = false| C[handle_single_file_edit_match] B -->|is_glob_pattern = true| D[validate_path] D -->|Ok - candidate exists| C D -->|Ok - candidate NOT exists| E[handle_glob_edit_match] D -->|Err: path_outside_root| C D -->|Err: other| CReviews (3): Last reviewed commit: "fix(edit_match): fail-safe on unknown va..." | Re-trigger Greptile