Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"malformed JSON string" #32

Closed
toddgrotenhuis opened this issue Apr 13, 2013 · 4 comments
Closed

"malformed JSON string" #32

toddgrotenhuis opened this issue Apr 13, 2013 · 4 comments

Comments

@toddgrotenhuis
Copy link

toddgrotenhuis commented Apr 13, 2013

I have gotten this message just a handful of times. I suspect it happens when an egg or potion is dropped. (a case that may not be handled by the results parser?) It happens when "plussing" an item.

malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "<html>\n<head>\n    ...") at /Library/Perl/5.12/JSON/Any.pm line 571.

@pjf
Copy link
Owner

pjf commented Apr 13, 2013

Aha! Having that happen when there's a drop makes perfect sense, since AFAIK the API has no way of signalling them. I suspect it's giving back some HTML page that hrpg then proceeds to choke up.

I'll report this upstream, but will leave this ticket open because I may be able to produce a workaround. :)

@pjf
Copy link
Owner

pjf commented Apr 24, 2013

I've got a workaround in dev for this. It's not elegant, but I'm testing it now. If it seems to be catching the error then it will be in the next release.

This can't be properly fixed until the upstream bug is resolved.

pjf added a commit that referenced this issue Apr 29, 2013
    * BUGFIX:   Detect drops from upstream and direct user to web
                interface. Kludges GH #32 and HabitRPG/habitica#815 .

    * BUILD:    New dependency: Try::Tiny.

    * FEATURE:  `hrpg help` now provides a help screen.
@pjf
Copy link
Owner

pjf commented Apr 29, 2013

The latest release (0.18) now has a workaround. There's a chance it may report an item has dropped on a general server error, but it gets around the problem of an ugly error when we don't get back valid JSON, and it should work even if you're doing something like a +5 to increment a task multiple times.

pjf@qapla:~$ hrpg + issue

Updating Fix any issue (x1) (80e85523-245c-4f00-be28-347180754b9a)

Looks like an item dropped! Check http://habitrpg.com/ to see what it is.
HP: 38/50 (+0.00)
XP: 86/300 (+8.50)
GP: 44.60 (+0.97)

As always, you can install with cpanm WebService::HabitRPG (although it may need an hour or so for all the CPAN mirrors to pick up on the new release).

hoelzro added a commit that referenced this issue Sep 2, 2017
Now that the API actually provides drop information, we can use it!

Fixes GH #32
@hoelzro
Copy link
Collaborator

hoelzro commented Sep 2, 2017

This is fixed in version 0.30 of the module!

@hoelzro hoelzro closed this as completed Sep 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants