Hostgroup search fails when use "class" for filtering

When I use hostgroup search, and try to use keyword “class” for filtering my hostgroups, Foreman crashes with next error. This keyword is suggested by tooltip that appears, when I start to search

Oops, we're sorry but something went wrong undefined method `klass' for nil:NilClass

Expected outcome:
Be able to filter hostgroups by puppetclass

Foreman and Proxy versions:

Distribution and version:
We run both Foreman and Puppet on Centos 8 Stream

Other relevant data:
We also noticed that if we get info about hostgroup via API, there is no information about Puppet classes and search is also generate the same error as I have described above.
We faced this issue afrer we had updated Foreman to version 3.2. In Foreman 1.24 and 2.5 everything works good.

p.s. Also I wonder if we can use Foreman API to manage puppetclasses? In API documentation for Foreman v3.2 there are no endpoints for puppetclasses.

Looks like a bug to me. The same happens on my foreman server with 3.5.2 and foreman_puppet 5.0.0 plugin.

Check the apidocs of your server: It should include apidocs of all your plugins.

Thanks for confirming this issue on newer version of Foreman.
But /apidoc shows nothing, only blank page. Maybe something is broken. I will take a closer look, thanks for advice.

Did you run foreman-rake apipie:cache on your machine?

Yeah, I try it but it didn’t change anything.
It’s not big problem to be honest. I wonder how to fix the search.

We fixed an error related to this which will be part of the new release. But if you want to try if it fixes your error, you can have a look at Fixes Host view permissions to search by puppetclass · theforeman/foreman_puppet@3722ec5 · GitHub

Thanks, I’ll try to apply this patch to our environmet. If this will help I’ll mark your reply as solution as soon as possible :slightly_smiling_face:

Unfortunately this patch didn’t help. At least search for hostgroups by using keyword “class” throws the same error.

I opened a new issue for this: Hostgroup search fails when use “class” for filtering · Issue #360 · theforeman/foreman_puppet · GitHub

1 Like

Great! Thanks! Please, let me know if you will need an extra information for this issue.

I patch my test environment (Foreman 3.2.1) with your changes from this issue and can confirm that everything works fine now. Thanks!

1 Like