Selectively silence warnings from the bazel downloader
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the feature request:
Provide a way to silence warnings from the Bazel downloader.
I'm pretty neutral on the implementation. Options include:
+ a command line arg that sets the log level for the [downloader](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java).
+ Eg: `--downloader_logging_level=<0 <= an integer <= 6>` mimicking [`--logging`](https://bazel.build/reference/command-line-reference#flag--logging).
+ an attribute on https://bazel.build/rules/lib/builtins/module_ctx#download as @aignas suggested in https://github.com/bazelbuild/rules_python/issues/2100
+ IMO this is probably the better option, as it can be set on a per-context basis. For example, `rules_python` would be updated to silence warnings _just_ for the pip downloads, and then other things using the downloader would still show warnings.
+ something that you fine folk come up with
### Which category does this issue belong to?
Core
### What underlying problem are you trying to solve with this feature?
https://github.com/bazelbuild/rules_python/issues/2100
The current implementation of `rules_python`'s experimental "use bazel downloader to download python packages" will search _all_ indexes - the primary index defined by `experimental_index_url` and all of the indexes defined by `experimental_extra_index_urls` - for _all_ packages.
However, only one of the python package indexes will contain the given package, and the rest will either not contain the package (404) or will fail auth (401). This results in a lot of WARNING messages:
```
$ bazel test //src/pyle_xc/fab/package_tester:web_api_test
Starting local Bazel server and connecting to it...
WARNING: Download from https://[REDACTED]/simple/rsa/ failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from https://[REDACTED]/simple/uv/ failed: class java.io.FileNotFoundException GET returned 404 Not Found
...
```
For python projects that have a lot of dependencies, this creates a wall of warnings in the terminal.
Current workarounds include:
+ use `experimental_index_url_overrides` in `rules_python`
+ Not super feasible when there are a lot of packages, as now multiple package definitions need to stay in sync (the requirements lock file and MODULE.bazel)
+ Use a single [virtual repository](https://cloud.google.com/artifact-registry/docs/repositories/virtual-overview).
+ This causes all packages to be downloaded from a single source and then 404 errors are real.
+ I'm trying to convince our software ops team to implement this, but it's slow going :upside_down_face:
### Which operating system are you running Bazel on?
gLinux
### What is the output of `bazel info release`?
release 7.2.0
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse HEAD` ?
_No response_
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start with src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java and compare its warning behavior with the --logging flag. Review the downloader and module_ctx download entry points, along with the linked rules_python issue, to choose the configuration scope. Done means the selected downloader warnings can be silenced without hiding unrelated downloader messages, with tests covering the chosen interface.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100