Adds a check that the annotation exists before reading it to compare its value.
Motivation for the change:
In the old JavaScript-based expression evaluation, indexing the map with a nonexistent key would simply result in an undefined value which would compare as false against the test value. In CEL it is a runtime error to index with a nonexistent key, so there should be an existence check before the access and comparison to ensure that the result comes back as a successful evaluation with a false result, rather than as an error.
How to manually test:
Check out cryostat3 with this PR and build
./smoketest.bash -Ot
Go to Automated Rules > Create, click a target in the miniature topology view
Click the match expression tooltip ? icon. Copy the suggested expression and paste it into the match expression box.
If the suggested annotation exists only on some targets and not others, then the evaluation would fail prior to this PR.
Welcome to Cryostat! 👋
Before contributing, make sure you have:
main
branch[chore, ci, docs, feat, fix, test]
To recreate commits with GPG signature
git fetch upstream && git rebase --force --gpg-sign upstream/main
Related to https://github.com/cryostatio/cryostat3/issues/511
Description of the change:
Adds a check that the annotation exists before reading it to compare its value.
Motivation for the change:
In the old JavaScript-based expression evaluation, indexing the map with a nonexistent key would simply result in an
undefined
value which would compare asfalse
against the test value. In CEL it is a runtime error to index with a nonexistent key, so there should be an existence check before the access and comparison to ensure that the result comes back as a successful evaluation with afalse
result, rather than as an error.How to manually test:
./smoketest.bash -Ot
?
icon. Copy the suggested expression and paste it into the match expression box.