bazelbuild / bazelbuild/bazel

Bazel should warn if an unknown feature is given

Open
#21,957 12 comments 0 reactions 0 assignees View on GitHub
not stale P4 team-Rules-CPP type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the bug:

You can provide Bazel with features with typos or completely non-existent and you wouldn't know about it.

### Which category does this issue belong to?

CLI

### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Here you can see I am providing the feature `blah` and it doesn't do anything.
This is also problematic if you give a comma separated features value rather than specifying it on the command line multiple times. `--features foo --features bar` vs `--features foo,bar`

```
❯ bazel build --features=blah //examples/c++:example_add
WARNING: Build option --features has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
INFO: Analyzed target //examples/c++:example_add (0 packages loaded, 2956 targets configured).
INFO: Found 1 target...
Target //examples/c++:example_add up-to-date:
bazel-bin/examples/c++/example_add
INFO: Elapsed time: 0.743s, Critical Path: 0.01s
```

### Which operating system are you running Bazel on?

Linux

### What is the output of `bazel info release`?

release 7.0.2

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

N/A

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

```text
N/A
```

### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No

### Have you found anything relevant by searching the web?

Seems like this is the default behavior.

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by tracing how Bazel parses the --features option and handles repeated versus comma-separated values. Reproduce the examples with an unknown feature, then inspect the existing feature validation or diagnostic tests if available. Done means unknown feature names produce a clear warning without breaking valid feature handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.