Bug #17360
closedFilter on FactValue with like-search fails with "malformed format string - % (ArgumentError)"
Description
Hi everyone,
I have been trying to create a filter for a role on the FactValue resource.
Applying filters with equals operator works perfectly fine, but filtering with a like search raises a "malformed format string - %k (ArgumentError)".
This happens both via WebUI and via hammer.
Here is the stacktrace hammer shows me when updating the filter via "hammer filter update --id <id> --search 'host ~ <name>'":
/opt/theforeman/tfm/root/usr/share/gems/gems/fast_gettext-1.1.0/lib/fast_gettext/vendor/string.rb:70:in `%': malformed format string - %k (ArgumentError)
from /opt/theforeman/tfm/root/usr/share/gems/gems/fast_gettext-1.1.0/lib/fast_gettext/vendor/string.rb:70:in `%'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.7.0/lib/hammer_cli/utils.rb:12:in `format'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.7.0/lib/hammer_cli/output/adapter/abstract.rb:32:in `print_error'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.7.0/lib/hammer_cli/output/output.rb:16:in `print_error'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.7.0/lib/hammer_cli/exception_handler.rb:45:in `print_error'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.7.0/lib/hammer_cli/exception_handler.rb:62:in `handle_general_exception'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.7.0/lib/hammer_cli/exception_handler.rb:28:in `handle_exception'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.7.0/lib/hammer_cli/abstract.rb:189:in `handle_exception'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.7.0/lib/hammer_cli/abstract.rb:26:in `rescue in run'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.7.0/lib/hammer_cli/abstract.rb:22:in `run'
from /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.7.0/bin/hammer:125:in `<top (required)>'
from /bin/hammer:23:in `load'
from /bin/hammer:23:in `<main>'
The same error message (malformed format string - %k) appears in the WebUI when applying a like filter on the facts page in the filter box, or when searching facts via hammer with a like search.
This was tested on Katello 3.1/Foreman 1.12.4, but since I could not find a ticket for this issue, I'm assuming this bug is still around.