cryostatio / cryostat-web

Web front-end for Cryostat: Secure JDK Flight Recorder management for containerized JVMs
https://cryostat.io/
Other
10 stars 20 forks source link

fix(matchexpr): tooltip hint checks for annotation existence before asserting value (backport #1275) #1280

Closed mergify[bot] closed 1 month ago

mergify[bot] commented 1 month ago

Welcome to Cryostat! 👋

Before contributing, make sure you have:

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 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:

  1. Check out cryostat3 with this PR and build
  2. ./smoketest.bash -Ot
  3. Go to Automated Rules > Create, click a target in the miniature topology view
  4. Click the match expression tooltip ? icon. Copy the suggested expression and paste it into the match expression box.
  5. If the suggested annotation exists only on some targets and not others, then the evaluation would fail prior to this PR.
    This is an automatic backport of pull request #1275 done by Mergify.
github-actions[bot] commented 1 month ago

Hi @mergify[bot]! Add at least one of the required labels to this PR

Required labels are : chore,ci,cleanup,docs,feat,fix,perf,refactor,style,test