Skip to content

Conversation

@KlotzAndrew
Copy link
Contributor

@KlotzAndrew KlotzAndrew commented Oct 21, 2025

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//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

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
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 21, 2025
@meta-codesync
Copy link
Contributor

meta-codesync bot commented Oct 21, 2025

@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.)

@KlotzAndrew KlotzAndrew marked this pull request as ready for review October 29, 2025 23:26
Copy link
Contributor

@scottcao scottcao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants