-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Silent failure when credentials file is malformed #18755
Description
Description of the bug:
When using remote build/remote caching, bazel can authenticate using a --google_credentials=path/to/creds.json flag to point to a JSON file containing credentials to authenticate with gcloud. If this flag points to a file that exists but is not valid json (e.g. empty), the bazel server crashes IllegalArgumentException and the client silently exists with nothing to report.
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Please see the following repository: https://github.com/stgpetrovic/bazel-creds-errors
You can find reproduce.sh there, with a full explanation in its README.md.
For having everything in one place, though, here's a quick way to reproduce it. I have a suggested fix there, but did not want to spend much time on it (e.g. adding test) before it's validated from your side. Let me know if you'd like me to contribute that fix, or a similar one.
Thanks!
B_TMP_DIR="/tmp/test_bazel_xxxxxxxxxxxxxx12"
rm -rf $B_TMP_DIR; mkdir $B_TMP_DIR; pushd $B_TMP_DIR
touch WORKSPACE
echo -e "cc_binary(name='main', srcs='main.cc')" >> BUILD
echo -e "void main() {}" >> main.cc
touch /tmp/mycredsfile.23213211.json
bazel build //:main --google_credentials=/tmp/mycredsfile.23213211.json --remote_cache=grpcs://remotebuildexecution.googleapis.com
echo $?
rm /tmp/mycredsfile.23213211.json
popd
rm -rf $B_TMP_DIR
Note that if the file does not exist (the IOException path) is OK since that gets caught and reported.
B_TMP_DIR="/tmp/test_bazel_xxxxxxxxxxxxxx12"
rm -rf $B_TMP_DIR; mkdir $B_TMP_DIR; pushd $B_TMP_DIR
touch WORKSPACE
echo -e "cc_binary(name='main', srcs='main.cc')" >> BUILD
echo -e "void main() {}" >> main.cc
rm /tmp/mycredsfile.23213211.json
bazel build //:main --google_credentials=/tmp/mycredsfile.23213211.json --remote_cache=grpcs://remotebuildexecution.googleapis.com
echo $?
rm /tmp/mycredsfile.23213211.json
popd
rm -rf $B_TMP_DIR
Which operating system are you running Bazel on?
Linux 6.1.25-1rodete1-amd64
What is the output of bazel info release?
release 6.2.1
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 master; git rev-parse HEAD ?
No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
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