Setting search returns Error 500

Hello everyone :slight_smile: ,
I was working with this issue where the settings search bar returns “Error: status code: 500”
On debugging, it turned out that description column being removed from the settings table in this pr: https://github.com/theforeman/foreman/blob/develop/db/migrate/20220124174632_drop_setting_fields.rb
caused the issue of “Unknown Attribute error” for description.
A hack would be to remove description from the search field but that isn’t very user friendly.
So in this post, I would love to get your suggestion/advice on the possible solution for this issue.

Thank you :smiley:

1 Like

Hi! :slight_smile:

I’d suggest pointing the autocomplete on SettingsController to the SettingRegistry#search_for method.

I know it might be painful to process the result into the autocomplete format, but I belive there is not much choice there.

I also believe we can reuse the scoped_search methods for processing results from database to do the heavy lifting :slight_smile:

2 Likes

If this already made it into a release (or multiple) it may also be valid to first disallow searching for the description. That at least allows searching for other things (like name), which is probably a safe cherry pick to a stable release. Then you can invest more time in a bigger solution.

3 Likes

I’m not sure if it’s a good approach, when it worked I used the description field for search quite a lot, usually I don’t know exactly what I’m looking for and therefore trying to search by some string that could be in the description. And it works quite well :smiley:

It’s more about a short term solution: today you can’t search at all. If you remove the description from fields then you can at least search on other fields. Granted, it’s not as useful but it’s better than an internal server error. Then you can safely look at a proper solution. When I looked at it I thought it wasn’t a trivial change and it can take more time to resolve. But I’d be happily proven wrong by a patch that resolves it properly.

1 Like