Confusing error message when deploying to incorrectly formatted hostname
mattnworb opened this issue · comments
If the hostname passed to helios deploy
looks like a URL (or simply contains a slash) when the --json
switch is present, a confusing error message Conversion = 'F'
is printed with no other output.
# creating the job
$ bin/helios -z http://localhost:5801 create testjob:1 some-image
Creating job: {"command":[],"created":null,"creatingUser":null,"env":{},"expires":null,"gracePeriod":null,"healthCheck":null,"hostname":null,"id":"testjob:1","image":"some-image","metadata":{},"networkMode":null,"ports":{},"registration":{},"registrationDomain":"","resources":null,"securityOpt":[],"token":"","volumes":{}}
Done.
testjob:1:2178b49ac982e92b87442b179b869b4414f770db
# regular deploy to a non-existent host
$ bin/helios --json -z http://localhost:5801 deploy testjob:1 some-host
{"host":"some-host","job":"testjob:1:2178b49ac982e92b87442b179b869b4414f770db","status":"HOST_NOT_FOUND"}
# deploy to host "foo/bar"
$ bin/helios --json -z http://localhost:5801 deploy testjob:1 foo/bar
Conversion = 'F'
To reduce any possible user confusion it would be nice if the HOST_NOT_FOUND
was still output.
The cause is that the slash is encoded as %2F
in the JSON response from the server and then this string is passed through printf
/ java.util.Formatter
:
$ bin/helios -vvv --json -z http://localhost:5801 deploy testjob:1 foo/bar
...
10:11:25.987 TRACE DefaultRequestDispatcher: rep: PUT http://127.0.0.1:5801/hosts/foo%252Fbar/jobs/testjob:1:2178b49ac982e92b87442b179b869b4414f770db?token=&user=mattbrown 400 105 {
"host" : "foo%2Fbar",
"job" : "testjob:1:2178b49ac982e92b87442b179b869b4414f770db",
"status" : "HOST_NOT_FOUND"
} gzip:false
java.util.UnknownFormatConversionException: Conversion = 'F'
at java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2691)
at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2720)
at java.util.Formatter.parse(Formatter.java:2560)
at java.util.Formatter.format(Formatter.java:2501)
at java.io.PrintStream.format(PrintStream.java:970)
at java.io.PrintStream.printf(PrintStream.java:871)
at com.spotify.helios.cli.command.JobDeployCommand.runWithJobId(JobDeployCommand.java:112)
at com.spotify.helios.cli.command.WildcardJobCommand.run(WildcardJobCommand.java:82)
at com.spotify.helios.cli.command.ControlCommand.run(ControlCommand.java:127)
at com.spotify.helios.cli.command.ControlCommand.run(ControlCommand.java:90)
at com.spotify.helios.cli.CliMain.run(CliMain.java:75)
at com.spotify.helios.cli.CliMain.main(CliMain.java:53)
For what it is worth this would probably also happen with any %
character in the response or anything else that might end up URL encoded