fix suggestion to include full path#1129
Open
KlotzAndrew wants to merge 1 commit intofacebook:mainfrom
Open
Conversation
This change returns a valid suggestion in the case of an invalid path to a BUCK file. This can come up from either making a typo in a target path or accidentially mismatching cases on a case-insensitive OS and then having a build run on a case-sensitive OS Before, we matched on the closest parent directory then returned that as a suggested path, which can be confusing if `root//cat` is not a valid location: ``` dir `root//animals/pets/cats` does not exist. Did you mean `root//cat`? ``` After, we now return the full path to the matched directory allowing copy+paste of the suggestion to fix: ``` dir `root//animals/pets/cats` does not exist. Did you mean `root//animals/pets/cat`? ``` PS: I have no idea if the tests pass, the README says they can only run inside meta so this is just a guess
Contributor
|
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D85162591. (Because this pull request was imported automatically, there will not be any future comments.) |
scottcao
reviewed
Nov 6, 2025
Contributor
scottcao
left a comment
There was a problem hiding this comment.
In general looks good. I will go and follow up on the e2e tests internally.
| suggestion.to_owned(), | ||
| match parent.path().join_normalized(suggestion) { | ||
| Ok(p) => p.as_str().to_owned(), | ||
| Err(_) => suggestion.to_owned() |
Contributor
There was a problem hiding this comment.
Nit: it's kinda weird to return the original suggestion on error since the suggestion is not relevant. Can we get the following behavior instead? On error, return NoSuggestion as suggestion and fire a soft_error!() that joining normalized paths unexpected failed when recommending suggestions.
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.
The current BUCK file suggestion usually returns an invalid path, this change returns a valid suggestion in the case of an invalid path to a BUCK file.
When you have a missing BUCK file, buck tries to suggest what you meant. Instead of returning the full path, it returns the directory the suggested BUCK file is in, which can be confusing and means the suggestion cannot be copy+pasted
e.g.
root//catis not a valid location:After, we now return the full path to the matched directory allowing copy+paste of the suggestion to fix:
PS: I have no idea if the tests pass, the README says they can only run inside meta so this is just a guess