Open itskingori opened 4 years ago
Parsing with Oj doesn't seem to give this error. Making the switch might be a convenient fix for this.
JSON
irb(main):004:0> JSON.parse("{\"comment\":\"Some gems seem to be missing from your /srv/bundle/cache directory.\\n\eCould not find rake-12.3.3 in any of the sources\"}\n")
Traceback (most recent call last):
1: from (irb):4
JSON::ParserError (783: unexpected token at '{"comment":"Some gems seem to be missing from your /srv/bundle/cache directory.\nould not find rake-12.3.3 in any of the sources"})
'
Oj
[6] pry(main)> Oj.load("{\"comment\":\"Some gems seem to be missing from your /srv/bundle/cache directory.\\n\eCould not find rake-12.3.3 in any of the sources\"}\n").first
=> ["comment",
"Some gems seem to be missing from your /srv/bundle/cache directory.\n\eCould not find rake-12.3.3 in any of the sources"]
hmmm this seems to be a more general problem
JSON.parse("\"\n\"")
does not work either
... but also this seems to mean that the jenkins server is at fault and not the client, since the \e
should have been escaped to \\e
right ?
so prefer to open an issue with jenkins + make sure jenkins is up to date and then see what they say about this issue
the \e
afaik usually is from an escape sequence, so that smells like some cli printing gone wrong :/
... can you reliably reproduce this or is this randomly happening or at a random position in the reply ?
I'm experiencing a
JSON::ParserError
because of a bad character (in my case it's0x1b
):Here's the stack trace that showed me where the issue was:
This is the
JSON.parse
we're hitting ...https://github.com/arangamani/jenkins_api_client/blob/72f49f2e7ef12d58a0e33856ca91962b2e27709b/lib/jenkins_api_client/client.rb#L807-L816
I've been able to replicate using this file (jenkins-log-with-bad-character.txt):