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.
Updated by Dominic Cleal almost 8 years ago
- Category set to Search
Trivially reproducible with:
$ bin/rails runner "FactValue.search_for('host ~ a')" Running via Spring preloader in process 26304 /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/fast_gettext-1.1.0/lib/fast_gettext/vendor/string.rb:70:in `%': too few arguments (ArgumentError) from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/fast_gettext-1.1.0/lib/fast_gettext/vendor/string.rb:70:in `%' from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activerecord-4.2.7.1/lib/active_record/sanitization.rb:132:in `sanitize_sql_array' from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activerecord-4.2.7.1/lib/active_record/sanitization.rb:26:in `sanitize_sql_for_conditions' from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activerecord-4.2.7.1/lib/active_record/relation/query_methods.rb:950:in `build_where' from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activerecord-4.2.7.1/lib/active_record/relation/query_methods.rb:584:in `where!' from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activerecord-4.2.7.1/lib/active_record/relation/query_methods.rb:574:in `where' from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/scoped_search-3.3.0/lib/scoped_search/definition.rb:268:in `block in register_named_scope!' [..]
I suspect the stack trace above could be issue #11178 where the error message is being misinterpreted, and the root cause is something more similar to the search above failing.
Updated by The Foreman Bot about 7 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/4664 added
Updated by Tomer Brisker about 7 years ago
- Translation missing: en.field_release set to 240
Updated by Kavita Gaikwad about 7 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset bcb747183e90eebf60bca672ccea81b05ba82810.