theforeman/foreman — pull request #1126 by eLobato (2014-01-03 16:00:24+00:00)
Title: Bug #3920: Prevent 500 ScopedSearch errors on the API

This PR applies a filter on every controller, around the index action.

It's functionality is basically to avoid 500 errors caused by broken
ScopedSearch queries, for instance "wrongfield = dlkas".

Tests just check that the appropriate template is rendered for the API, and in the UI case it checks the flash message and an appropriate redirection.

Without this PR, wrongly formed queries will result on 500 errors from the API and the UI side. Some of the controllers already implemented a fix for this, so this functionality was extracted and applied across all controllers.

Here's a list of the controllers where this is fixed (all of them except 2):

500: settings - fixed
models - fixed
images - fixed
architectures - fixed
media - fixed
roles - fixed
ptables - fixed
operatingsystems - fixed
environments - fixed
domains - fixed
common_parameters - fixed
subnets - fixed

200: compute_resources - fixed
reports - fixed
users - fixed
lookup_values - fixed
hostgroups - fixed
config_templates - fixed
puppetclasses - fixed
lookup_keys - fixed
audits - fixed

fact_values
hosts
are hard to fix because of post processing after search. Error handling is done in the controller itself, not on application_controller.

n/a: statistics
dashboard
facts
about
compute_resources_vms

http://projects.theforeman.org/issues/3920