malformedjsonexception stops flow even when using catch

53 views
Skip to first unread message

David Pritchard

unread,
Nov 6, 2019, 5:07:55 AM11/6/19
to Automate
I have a flow that makes an HTTP request and then uses jsondecode to decode the response. When an invalid response comes back (no doubt just a bunch of HTML), the flow aborts with the error "malformedjsonexception", despite the fact that I have a catch at the beginning of the flow. I'll post the full error message in a second when I manage to extract it from my phone. 

I could perhaps test for the presence of the character "<" in the response (which is what the error message mentions), but I wonder why the catch block doesn't prevent the flow from stopping. 

David Pritchard

unread,
Nov 6, 2019, 5:23:53 AM11/6/19
to Automate
1558954@55: com.llamalab.json.MalformedJsonException: Illegal character '<' at line 85

El Cid

unread,
Nov 6, 2019, 9:30:31 AM11/6/19
to Automate
You may need to show an image of your flow, as we do not know where the catch failure is and how you have applied it.

David Pritchard

unread,
Nov 7, 2019, 4:09:15 AM11/7/19
to Automate

Alarm flow for forum post.png

I've marked the catch block and the block that throws the error (55) in red. I've marked a block in blue that I added to check for the "<" character, in the hope of preventing the error from happening. Once you get to "when in time window..." the flow moves across from left to right.

El Cid

unread,
Nov 7, 2019, 5:45:26 AM11/7/19
to Automate
from the documentation

"This block will only catch and retry through the FAIL path for a maximum of retries, any additional failure will cause the fiber to stop. The retry count is reset to zero every time the block is executed through the IN dot."

what is the response code from the http request? try outputing it and show in a toast.

David Pritchard

unread,
Nov 7, 2019, 12:25:07 PM11/7/19
to Automate

But it never goes to the catch fail block. It aborts immediately.
I'll have to wait for it to fail to get the response code. I imagine it's a load of HTML. 

Henrik "The Developer" Lindqvist

unread,
Nov 7, 2019, 12:48:54 PM11/7/19
to Automate
So the flow actually stops?

David Pritchard

unread,
Nov 7, 2019, 3:06:03 PM11/7/19
to Automate
Yep.

2019-11-01 07:58:02.217 INFO 1558954@32: Expression true?
2019-11-01 07:58:02.219 INFO 1558954@14: HTTP request
2019-11-01 07:58:03.097 INFO 1558954@37: Expression true?
2019-11-01 07:58:03.098 INFO 1558954@55: Variable set
2019-11-01 07:58:03.105 FAIL 1558954@55: com.llamalab.json.MalformedJsonException: Illegal character '<' at line 85
2019-11-01 07:58:03.106 INFO 1558954@55: Stopped by failure

Henrik "The Developer" Lindqvist

unread,
Nov 7, 2019, 3:22:32 PM11/7/19
to Automate
Odd. How is the Failure catch block configured?

David Pritchard

unread,
Nov 7, 2019, 3:43:25 PM11/7/19
to Automate
Retry limit = 20

I can't just see any more settings. No output variables.

Henrik "The Developer" Lindqvist

unread,
Nov 7, 2019, 9:26:42 PM11/7/19
to Automate
Maybe your flow fail 21 times?

Is there's any "resumed after restart" message logged?

David Pritchard

unread,
Nov 8, 2019, 3:54:51 AM11/8/19
to Automate
Nope, you have to go back quite a few days to find the previous "resumed after restart". From 31st October, when it last restarted, there were seven exceptions caught by the catch block:

2019-10-31 18:26:22.087 INFO 1558954@35: Resumed after restart
2019-10-31 18:26:22.115 INFO 1558954@35: Time window?
2019-10-31 18:26:22.116 DBUG 1558954@35: Reset start of window alarm at FRI NOV 01 07:44:00 GMT+01:00 2019
2019-11-01 07:44:00.096 INFO 1558954@17: HTTP request
2019-11-01 07:44:00.157 FAIL 1558954@17: android.system.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)
2019-11-01 07:44:00.173 INFO 1558954@53: Delay
2019-11-01 07:46:00.191 INFO 1558954@54: Time window?
2019-11-01 07:46:00.238 INFO 1558954@17: HTTP request
2019-11-01 07:46:00.314 FAIL 1558954@17: android.system.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)
2019-11-01 07:46:00.329 INFO 1558954@53: Delay
2019-11-01 07:48:00.350 INFO 1558954@54: Time window?
2019-11-01 07:48:00.355 INFO 1558954@17: HTTP request
2019-11-01 07:48:00.594 FAIL 1558954@17: android.system.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)
2019-11-01 07:48:00.606 INFO 1558954@53: Delay
2019-11-01 07:50:00.624 INFO 1558954@54: Time window?
2019-11-01 07:50:00.666 INFO 1558954@17: HTTP request
2019-11-01 07:50:00.740 FAIL 1558954@17: android.system.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)
2019-11-01 07:50:00.759 INFO 1558954@53: Delay
2019-11-01 07:52:00.777 INFO 1558954@54: Time window?
2019-11-01 07:52:00.829 INFO 1558954@17: HTTP request
2019-11-01 07:52:00.905 FAIL 1558954@17: android.system.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)
2019-11-01 07:52:00.916 INFO 1558954@53: Delay
2019-11-01 07:54:00.939 INFO 1558954@54: Time window?
2019-11-01 07:54:00.944 INFO 1558954@17: HTTP request
2019-11-01 07:54:01.091 FAIL 1558954@17: android.system.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)
2019-11-01 07:54:01.114 INFO 1558954@53: Delay
2019-11-01 07:56:01.121 INFO 1558954@54: Time window?
2019-11-01 07:56:01.123 INFO 1558954@17: HTTP request
2019-11-01 07:56:01.164 FAIL 1558954@17: android.system.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)
2019-11-01 07:56:01.176 INFO 1558954@53: Delay
2019-11-01 07:58:01.195 INFO 1558954@54: Time window?
2019-11-01 07:58:01.208 INFO 1558954@17: HTTP request
2019-11-01 07:58:01.655 INFO 1558954@34: Expression true?
2019-11-01 07:58:01.663 INFO 1558954@18: Variable set
2019-11-01 07:58:01.675 INFO 1558954@19: Variable set
2019-11-01 07:58:01.677 INFO 1558954@21: Variable set
2019-11-01 07:58:01.680 INFO 1558954@23: Variable set
2019-11-01 07:58:01.683 INFO 1558954@24: Variable set
2019-11-01 07:58:01.683 INFO 1558954@22: HTTP request
2019-11-01 07:58:02.217 INFO 1558954@32: Expression true?
2019-11-01 07:58:02.219 INFO 1558954@14: HTTP request
2019-11-01 07:58:03.097 INFO 1558954@37: Expression true?
2019-11-01 07:58:03.098 INFO 1558954@55: Variable set
2019-11-01 07:58:03.105 FAIL 1558954@55: com.llamalab.json.MalformedJsonException: Illegal character '<' at line 85
2019-11-01 07:58:03.106 INFO 1558954@55: Stopped by failure

David Pritchard

unread,
Nov 8, 2019, 4:00:48 AM11/8/19
to Automate
Incidentally, I've realised that I do need to modify my flows to make them loop through the failure catch block, because otherwise the retry counter will never be reset - although that doesn't seem to be the cause in this case. 

Henrik "The Developer" Lindqvist

unread,
Nov 8, 2019, 3:44:17 PM11/8/19
to Automate
Just in the log you posted there's 8 retries. Maybe there's 12 more prior to the "Resumed after restart".
The flow should reconnect to the IN dot on the Failure catch block, so the "retry count" is reset, otherwise your flow will stop.

David Pritchard

unread,
Nov 8, 2019, 4:17:40 PM11/8/19
to Automate
I imagine the counter doesn't survive a reboot of the phone, correct? If I go back to when I'm sure the phone was rebooted, I count 16 errors which went through the failure catch block and then onto the subsequent delay block. Anyway, I've modified the flows to go back through the failure catch block, so let's see if this recurs. 

David Pritchard

unread,
Nov 8, 2019, 4:23:46 PM11/8/19
to Automate
If the counter does survive a restart, then the mystery is solved. Between the last "stopped by user" and the "stopped by failure" there are exactly 20 errors caught by the failure catch block.

Henrik "The Developer" Lindqvist

unread,
Nov 8, 2019, 9:21:48 PM11/8/19
to Automate
The retry counter is like any other variable value, so it "survive" device reboot and "resumed after restart".
Good, case closed.

David Pritchard

unread,
Nov 9, 2019, 5:16:04 AM11/9/19
to Automate
Thanks a lot for your help Henrik
Reply all
Reply to author
Forward
0 new messages