It looks like ifvarclass is one of few places in CFEngine that does not automatically canonify:
Is there a reason why ifvarclass – which takes a variable by design – does not automatically canonify that variable before checking if there’s a matching class?
Yes, it's true that
ifvarclass, and it's aliases
unless do not
automatically canonify when checking a class.
Historically there was no automatic canonfication in cfengine. If you defined a class or var that contains an invalid character you would get an error. Based on user feedback this restriction loosened over time. Now if you define a class using an invalid character, the agent does not log an error, (it will let you know that it was automatically canonified in verbose mode)
Cfengine doesn't automatically canonify when checking with
expressions because that would prevent the use of complex expressions
Here is an example that shows automatic canonification as well as a contrived
use case for conditioning
ifvarclass using a class expression.
R: my_illegal_class R: my-illegal-class is NOT defined (as expected, its invalid) R: my_illegal_class is defined R: Slice and dice using `with`
See making decisions based on classes in the language concepts section of the reference manual.