Host searches for discovered hosts that include `has facts.XXX` and `facts.YYY = ZZZ` in same query fails

Problem:
Given a discovered host with facts
fact1 = foo
fact2 = bar
the search query has facts.fact1 and facts.fact2 = bar returns no hosts.
A similar query for provisioned hosts does work.
Expected outcome:
A query has facts.x and facts.y = z should return all hosts that have a fact named x with any value and a fact y with value z for both discovered and provisioned hosts.

Foreman and Proxy versions:
3.13

Foreman and Proxy plugin versions:
Katello 4.15

Distribution and version:
Oracle Linux 9

Other relevant data:

Could you try something like this as a workaround?

facts.fact1 != "some value that's definitely not there" and facts.fact2 = bar

The first part should effectively act as a not-null kind of check

yeah, that does work. I just thought it was odd that has syntax works in conjunction with other comparisons for actual hosts but not in discovery rules. Is that expected or should I open a bug?

Open a bug please. I just wanted to suggest a workaround to unblock you until someone actually fixes that

1 Like