Invalid json returned for mode=history

Report & discuss bugs found in SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
cltdba
Newbie
Newbie
Posts: 15
Joined: September 21st, 2012, 1:08 am

Invalid json returned for mode=history

Post by cltdba »

Example api call for history json:

Code: Select all

http://localhost:8080/api?output=json&apikey=myApiKey&limit=15&mode=history
Excerpt of returned json where error lies:

Code: Select all

"show_details": "True",
                "script_log": "|  + Codec ID: A_DTS\nVariable values: \n -> (dl_path) [arg1] = /media/sabnzbd/post_process
When output is parsed through JSONLint it gives the following error. Other applications are reporting similar invalid character and/or parse errors.

Code: Select all

Parse error on line 9:
...      "script_log": "|  + Codec ID: A_DT
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
Example log from couchpotatoserver:

Code: Select all

12-29 15:12:51 INFO [0m[hpotato.core.plugins.base] Opening url: http://localhost:8080/api?output=json&apikey=xxx&limit=15&mode=history, params: [][0m
12-29 15:12:51 ERROR [31m[.core.downloaders.sabnzbd] Failed getting history json: Traceback (most recent call last):
  File "/Applications/CouchPotatoServer/couchpotato/core/downloaders/sabnzbd/main.py", line 86, in getAllDownloadStatus
    'limit': 15,
ValueError: Invalid control character at: line 1 column 116343 (char 116343)
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Invalid json returned for mode=history

Post by shypike »

When you cut short all logging, it's a bit hard to tell what's going on.

Code: Select all

"show_details": "True",
                "script_log": "|  + Codec ID: A_DTS\nVariable values: \n -> (dl_path) [arg1] = /media/sabnzbd/post_process
Do you mean to tell that the end quote is missing?
Does the string continue on the next line, but is SABnzbd splitting lines incorrectly?
What is the real output?
cltdba
Newbie
Newbie
Posts: 15
Joined: September 21st, 2012, 1:08 am

Re: Invalid json returned for mode=history

Post by cltdba »

Where can I send you the full json output? It appears it is complaining about the colon just after show details.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Invalid json returned for mode=history

Post by shypike »

[email protected]
(Please add the URL of this post.)
GijsW
Newbie
Newbie
Posts: 1
Joined: January 20th, 2013, 5:35 pm

Re: Invalid json returned for mode=history

Post by GijsW »

Seems I have a simlar issue:

Code: Select all

01-20 23:54:47 INFO [hpotato.core.plugins.base] Opening url: http://localhost:8080/api?output=json&apikey=xxx&limit=15&mode=history, params: []01-20 23:54:48 ERROR [tato.core.plugins.renamer] Failed checking for release in downloader: Traceback (most recent call last):
  File "/volume1/@appstore/couchpotatoserver/share/CouchPotatoServer/couchpotato/core/plugins/renamer/main.py", line 563, in checkSnatched
    nzbname = self.createNzbName(rel_dict['info'], movie_dict)
  File "/volume1/@appstore/couchpotatoserver/share/CouchPotatoServer/couchpotato/core/plugins/base.py", line 260, in createNzbName
    return '%s%s' % (toSafeString(data.get('name')[:127 - len(tag)]), tag)
TypeError: 'int' object has no attribute '__getitem__'
cltdba
Newbie
Newbie
Posts: 15
Joined: September 21st, 2012, 1:08 am

Re: Invalid json returned for mode=history

Post by cltdba »

Finally remembered to send you the json.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Invalid json returned for mode=history

Post by shypike »

cltdba and GijsW.
Both your examples validate fine in http://jsonlint.com/

I also tried http://json.parser.online.fr but I don't see any error messages there either.
Maybe they're there, but I don't see them.
cltdba
Newbie
Newbie
Posts: 15
Joined: September 21st, 2012, 1:08 am

Re: Invalid json returned for mode=history

Post by cltdba »

I'm not sure what you're doing differently than me? I paste the entire contents into jsonlint and upload the file to json parser. I know little to nothing about json so I could be doing this all wrong.

Code: Select all

Parse error on line 71:
...      "script_log": "Loading config from
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
Json Parser Online complains of a missing comma in the string below. It also gives an eval error of: SyntaxError: JSON Parse error: Expected ']'

Code: Select all

./scriptlog?name=SABnzbd_nzo_GSGha4">(More)</a>"


All 15 reported parse errors are variations of the below block.

Code: Select all

{
"name":"Script",
"actions":[
"Processing succeeded for /media/sabnzbd/post_process/American.Horror.Story.S02E09.720p.WEB-DL.DD5.1.H.264-ECI/American.Horror.Story.S02E09.The.Coat... <a href="./scriptlog?name=SABnzbd_nzo_GSGha4">(More)</a>"
]
}
It looks like the issues is because of the double quote starting at href=. If you remove them, it no longers lends a parse error. If you escape them with "\" it also parses. This particular example is output from the sabToSickBeard.py post processing script. Perhaps the fix is to replace all occurrences of double quotes with a backslash followed by double quote.

This parses:

Code: Select all

{
"name":"Script",
"actions":[
"Processing succeeded for /media/sabnzbd/post_process/American.Horror.Story.S02E09.720p.WEB-DL.DD5.1.H.264-ECI/American.Horror.Story.S02E09.The.Coat... <a href=./scriptlog?name=SABnzbd_nzo_GSGha4>(More)</a>"
]
}
So does this:

Code: Select all

{
"name":"Script",
"actions":[
"Processing succeeded for /media/sabnzbd/post_process/American.Horror.Story.S02E09.720p.WEB-DL.DD5.1.H.264-ECI/American.Horror.Story.S02E09.The.Coat... <a href=\"./scriptlog?name=SABnzbd_nzo_GSGha4\">(More)</a>"
]
}
cltdba
Newbie
Newbie
Posts: 15
Joined: September 21st, 2012, 1:08 am

Re: Invalid json returned for mode=history

Post by cltdba »

This "error" is annoying.. When I copy and paste into http://json.parser.online.fr, it parses just fine........ back to the proverbial drawing board..
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Invalid json returned for mode=history

Post by shypike »

This fragment is handled correctly:

Code: Select all

    ./scriptlog?name=SABnzbd_nzo_GSGha4">(More)</a>"
In the JSON file that you sent me, the actual data is:

Code: Select all

    ./scriptlog?name=SABnzbd_nzo_GSGha4\">(More)</a>"
Notice the backslash before the embedded quote?
Isn't what you show in your post just the rendering of the pretty-printer you are using?
cltdba
Newbie
Newbie
Posts: 15
Joined: September 21st, 2012, 1:08 am

Re: Invalid json returned for mode=history

Post by cltdba »

Yep, you're correct. I noticed the same after I pasted the log contents into the json parser instead of uploading it. None of the current CP logs are producing the error. If it pops up again I'll grab fresh logs and json.
Post Reply