Skip to content

Commit 98d1b8d

Browse files
committed
Prevent script failure on empty client_id
In `test/launch_local_env.sh`, the check for the `client_id` could fail with a "unary operator expected" error if the `jq` command produced an empty result. This would happen if the config file path was invalid or the `client_id` key was missing, causing the script to crash abruptly. By wrapping the command substitution in double quotes, the comparison remains syntactically valid even with an empty string. This allows the script to fail gracefully and display its own helpful error message instead of exiting with a shell error. Additionally, a stray quotation mark is removed from a command example in the README.
1 parent 2c5f33d commit 98d1b8d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ It will run services on the following local ports:8001 8091 8443 8888
171171
5. Run `cadctl` with the payload file created by `test/generate_incident.sh` and proxy as well as the backplane URL set to localhost
172172

173173
```bash
174-
BACKPLANE_URL=https://localhost:8443 HTTP_PROXY=http://127.0.0.1:8888 HTTPS_PROXY=http://127.0.0.1:8888 BACKPLANE_PROXY=http://127.0.0.1:8888 ./bin/cadctl investigate --payload-path ./payload --log-level debug"
174+
BACKPLANE_URL=https://localhost:8443 HTTP_PROXY=http://127.0.0.1:8888 HTTPS_PROXY=http://127.0.0.1:8888 BACKPLANE_PROXY=http://127.0.0.1:8888 ./bin/cadctl investigate --payload-path ./payload --log-level debug
175175
```
176176
6. Close the local infrastructure when done by sending SIGINT (Ctrl+C) to the launch_local_env.sh
177177

test/launch_local_env.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ check_presence "haproxy"
2828
check_presence "proxytunnel"
2929

3030
#loading env vars
31-
. ${CAD_REPO_PATH}/test/set_stage_env.sh
31+
. ${CAD_REPO_PATH}/test/set_stage_env.sh
3232

3333
#checking env vars
3434
set +u
@@ -38,7 +38,7 @@ if [[ -z "${OCM_BACKPLANE_REPO_PATH}" ]]; then
3838
fi
3939
set -u
4040

41-
if ! [ $(cat ${OCM_BACKPLANE_REPO_PATH}/configs/ocm.json | jq -r .client_id) = "ocm-backplane-staging" ]; then
41+
if ! [ "$(cat ${OCM_BACKPLANE_REPO_PATH}/configs/ocm.json | jq -r .client_id)" = "ocm-backplane-staging" ]; then
4242
echo "OCM Backplane ocm.json (${OCM_BACKPLANE_REPO_PATH}/configs/ocm.json) isn't the ocm-backplane-staging config."
4343
echo "Please get the config from a backplane pod on a staging backplanes0* cluster (in /ocm inside the pod)"
4444
echo "and place it in the configs subdirectory of the backplane-api repo."

0 commit comments

Comments
 (0)