Project

General

Profile

Actions

Bug #13559

closed

Exception not printed with `%': malformed format string - T (ArgumentError) error

Added by Dirk Mayer almost 9 years ago. Updated almost 2 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
Hammer core
Target version:
-
Difficulty:
Triaged:
No
Team Backlog:
Fixed in Releases:
Found in Releases:
In Kanboard:

Description

Using the following hammer command from command line failed withe a ruby exception:

hammer host create --environment-id 1 --architecture-id 1 --domain-id 1 --puppet-proxy-id 1 --operatingsystem-id 1 --hostgroup-id 2 --provision-method build --ip '172.17.31.12' --mac 'aa:aa:aa:aa:aa:aa' --name 'host1.localdomain' --subnet-id 1 --build 1 --enabled 1 --managed 1 --puppet-ca-proxy-id 1 --root-pass 'mycomplexpass' --interface 'primary=true,provision=true,type=interface'

Returning ruby exception:
/opt/theforeman/tfm/root/usr/share/gems/gems/fast_gettext-0.9.2/lib/fast_gettext/vendor/string.rb:70:in `%': malformed format string - T (ArgumentError)
from /opt/theforeman/tfm/root/usr/share/gems/gems/fast_gettext-0.9.2/lib/fast_gettext/vendor/string.rb:70:in `
'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/utils.rb:12:in `format'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/output/adapter/abstract.rb:27:in `print_error'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/output/output.rb:16:in `print_error'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/exception_handler.rb:45:in `print_error'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/exception_handler.rb:62:in `handle_general_exception'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/exception_handler.rb:28:in `handle_exception'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/abstract.rb:189:in `handle_exception'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/abstract.rb:26:in `rescue in run'
from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/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.5.1/bin/hammer:125:in `<top (required)>'
from /usr/bin/hammer:23:in `load'
from /usr/bin/hammer:23:in `<main>'

The exactly same command worked with the version of hammer installed with foreman 1.9.3

The foreman installation is running on RHEL 7.2

rpms:
  1. yum list hammer_cli

Installed Packages
tfm-rubygem-hammer_cli.noarch 0.5.1-1.el7
tfm-rubygem-hammer_cli_foreman.noarch 0.5.1-1.el7
Available Packages
rubygem-hammer_cli.noarch 0.3.0-1.el7
rubygem-hammer_cli_foreman.noarch

Actions #1

Updated by Dirk Mayer almost 9 years ago

After further investigation it became obvious that the problem came from a foreman hook which executed withe an error.
There was a from package installed. Withe the change to foreman 1.10 the rubygem rpm packages changed.
Instead of rubygem-jgrep the package tfm-rubygem-jgrep is now necessary to execute the hooks successful, and therefore also the hammer command.

Bug can be closed

Actions #2

Updated by Dominic Cleal almost 9 years ago

  • Subject changed from Create new host failed with exception to Exception not printed with `%': malformed format string - T (ArgumentError) error

The server side exception was probably caused by the hook, but the client side should still print the error without a string formatting error. Which locale are you using when running Hammer? It might be an issue in a translation.

Actions #3

Updated by Dirk Mayer almost 9 years ago

Local is set to english at the system.

[root@host01 ~]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Actions #4

Updated by Dominic Cleal almost 9 years ago

I'd perhaps guess then that somehow a message from the server is being passed through the % string formatter as the format string rather than an argument.

It looks like the output handler passes all messages through the % formatter, yet the exception handler is always interpolating parameters, messages etc. straight into the error message it passes to the formatter, which is bad. The exception handler should pass the string (e.g. Error: %s) to the output handler along with the argument (which is the dangerous bit), not interpolate it first.

Actions #5

Updated by Tomáš Strachota almost 9 years ago

Dominic's assumption is probably correct. Dirk, could you please attach output of the command executed with -d so that we see what data flew through the error handling?

Actions #6

Updated by Tomáš Strachota almost 9 years ago

  • Status changed from New to Need more information
Actions #7

Updated by Anonymous over 7 years ago

Dirk, any news here?

Actions #8

Updated by Dirk Mayer over 7 years ago

Sorry, i cant reproduce this error any more. Switched to Centos 7.3 and foreman v1.15.0

Actions #9

Updated by Anonymous over 7 years ago

  • Status changed from Need more information to Resolved

thanks!

Actions #10

Updated by Sam Smith almost 2 years ago

When it comes to essay writing, some students find it challenging to write a carefully crafted ( https://us.masterpapers.com/ ), high quality original paper by the end of the day. no matter how big your workload is, they will immediately provide you with first-class service.

Actions

Also available in: Atom PDF