cryostatio / cryostat

Other
7 stars 8 forks source link

[Bug] Match expression evaluation fails if expression references property not available on all targets #510

Closed andrewazores closed 3 weeks ago

andrewazores commented 3 weeks ago

Current Behavior

For example, testing a match expression like target.labels.url != '' throws an exception if the target evaluated does not have a url key in its labels map. This results in the evaluation request failing prematurely and returning an HTTP 400 response. This should be more lenient and return a successful response with a false result instead, or else expressions that test for map entries on labels or annotations are very likely to fail unless all of the discovered targets happen to have the key being tested for.

Expected Behavior

No response

Steps To Reproduce

No response

Environment

No response

Anything else?

No response

andrewazores commented 3 weeks ago

Not a real bug: the user can and should write this as has(target.labels.url) && target.labels.url != ''.

andrewazores commented 3 weeks ago

Alternatively, the in operator can be used: 'io.buildah.version' in target.labels && target.labels['io.buildah.version'] == '1.29.0'