-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error on invalid -//foo
and -@repo//foo
options
#16563
Conversation
@aranguyen Could you review this PR? |
Is there any more discussion around this and why putting the patterns after |
It's sufficient if you know about it, but the error message you get if you don't doesn't give any indication of this being how to fix your command line. Instead of catching this case and emitting a more helpful error message, it seemed simpler to just make the most common, unambiguous case work out of the box. I don't have more context than https://github.com/CodeIntelligenceTesting/cifuzz/pull/383#discussion_r1005694516 and similar past experiences that myself or coworkers had with this limitation. Given his reaction to the PR, maybe @brentleyjones can provide a separate opinion. |
I've just run into the same situation myself, and agree that it's hard to know when you need |
5a8944c
to
f50af3b
Compare
IIUC this is a quite common convention for CLI tools, and while it is confusing I fear changing things will only move confusion around, not reduce it. The one example that I believe is cited in the code comments is that relative labels (which I personally use more often) behave differently. It's also liable to cause confusion around starlark-defined flags, which can look like target patterns but are indeed flags. My interest here is keeping command-line parsing semantics as tight as possible so that any attempted automated introspection of command lines doesn't need to be too smart. |
I agree that not supporting all negative target patterns has potential to create confusion in different places and that supporting any kind of new syntax will make command line parsing more difficult. Starlark flags shouldn't add to the confusion though as they always starts with two dashes whereas negative target patterns start with one - isn't that a clean separation? Given that, would you support a version of this PR that doesn't add support for absolute negative target patterns without a |
I'm thinking of how one might be tricked into thinking
As long as it can be done tastefully sure. Thought it may not be me stamping it, I'm mainly here because I have an interest in parsing semantics. |
@fmeum Thank you very much for sending the PR. I just had the sync with the team and brought up your PR. We agree with #16563 (comment) and will be supportive of reviewing another PR that shows a more descriptive error. |
`-//foo` and `-@repo//foo` are always invalid Bazel options, but are usually meant to be either negative target patterns (which have to come after the `--` separator) or Starlark options (which always start with `--`). With this commit, the error shown to the user mentions these two situations and how to fix the issue in each case.
f50af3b
to
81b8589
Compare
--
separator-//foo
and -@repo//foo
options
@aranguyen I updated the commit and the PR description, please take another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
@bazel-io fork 6.3.0 |
`-//foo` and `-@repo//foo` are always invalid Bazel options, but are usually meant to be either negative target patterns (which have to come after the `--` separator) or Starlark options (which always start with `--`). With this commit, the error shown to the user mentions these two situations and how to fix the issue in each case. Closes bazelbuild#16563. PiperOrigin-RevId: 486920951 Change-Id: I9390d3859aa62c2b67eac05cb96a06209a9b7c36
`-//foo` and `-@repo//foo` are always invalid Bazel options, but are usually meant to be either negative target patterns (which have to come after the `--` separator) or Starlark options (which always start with `--`). With this commit, the error shown to the user mentions these two situations and how to fix the issue in each case. Closes #16563. PiperOrigin-RevId: 486920951 Change-Id: I9390d3859aa62c2b67eac05cb96a06209a9b7c36 Co-authored-by: Fabian Meumertzheim <[email protected]>
-//foo
and-@repo//foo
are always invalid Bazel options, but are usually meant to be either negative target patterns (which have to come after the--
separator) or Starlark options (which always start with--
).With this commit, the error shown to the user mentions these two situations and how to fix the issue in each case.