question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unexpected/unparsable response

See original GitHub issue

When calling FirebaseMessaging.getInstance().send(message), sometimes it failes with strange exception. Sometimes no errors for a day, sometime hundreds or thousands errors. Average error rate was about 3% mid december but is much higher today.

i checked Firebase Cloud Messaging Api in Google Cloud Platform console and see increasing 404 answer for Api Method google.firebase.fcm.v1.FcmService.SendMessage

I tried to understand the code and i think the http answer is not as expected. Probably this is related to the firebase server infrastructure, but sdk should not fail on parsing the error and answer some server Exception instead?.

java.lang.IllegalArgumentException: key details at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:900) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parse(JsonParser.java:360) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parse(JsonParser.java:318) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:162) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:144) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.safeParse(FirebaseMessagingClientImpl.java:308) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.createException(FirebaseMessagingClientImpl.java:292) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.createException(FirebaseMessagingClientImpl.java:282) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.internal.AbstractHttpErrorHandler.handleHttpResponseException(AbstractHttpErrorHandler.java:57) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.internal.ErrorHandlingHttpClient.send(ErrorHandlingHttpClient.java:108) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.internal.ErrorHandlingHttpClient.sendAndParse(ErrorHandlingHttpClient.java:72) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.messaging.FirebaseMessagingClientImpl.sendSingleRequest(FirebaseMessagingClientImpl.java:127) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.messaging.FirebaseMessagingClientImpl.send(FirebaseMessagingClientImpl.java:113) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.messaging.FirebaseMessaging$1.execute(FirebaseMessaging.java:135) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.messaging.FirebaseMessaging$1.execute(FirebaseMessaging.java:132) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.internal.CallableOperation.call(CallableOperation.java:36) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.messaging.FirebaseMessaging.send(FirebaseMessaging.java:102) ~[firebase-admin-7.1.0.jar:?] at com.google.firebase.messaging.FirebaseMessaging.send(FirebaseMessaging.java:86) ~[firebase-admin-7.1.0.jar:?] at de.k2interactive.qeep.api.firebase.FirebaseAdminApi.sendMessage(FirebaseAdminApi.java:70) ~[classes/:?] at de.k2interactive.qeep.api.firebase.FirebaseSinkV1Impl.sendSingleMessageInt(FirebaseSinkV1Impl.java:130) ~[classes/:?] at de.k2interactive.qeep.api.notification.NotificationSink.pushFcmReactivation(NotificationSink.java:356) ~[classes/:?] at de.k2interactive.qeep.jobs.FcmReactivationJob.lambda$sendAll$0(FcmReactivationJob.java:89) ~[qeep-jobs-55.jar:?] at java.lang.Thread.run(Unknown Source) [?:?] Caused by: java.lang.IllegalArgumentException: key details, field private java.util.Map com.google.firebase.messaging.internal.MessagingServiceErrorResponse.error at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:900) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parse(JsonParser.java:451) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:787) ~[google-http-client-1.38.0.jar:1.38.0] ... 22 more Caused by: java.lang.IllegalArgumentException: key details, field private java.util.Map com.google.firebase.messaging.internal.MessagingServiceErrorResponse.error at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:900) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parseMap(JsonParser.java:679) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:783) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parse(JsonParser.java:451) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:787) ~[google-http-client-1.38.0.jar:1.38.0] ... 22 more Caused by: java.lang.IllegalArgumentException: expected collection or array type but got class java.lang.Object at com.google.common.base.Preconditions.checkArgument(Preconditions.java:164) ~[guava-29.0-android.jar:?] at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:67) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:724) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parseMap(JsonParser.java:679) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:783) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parse(JsonParser.java:451) ~[google-http-client-1.38.0.jar:1.38.0] at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:787) ~[google-http-client-1.38.0.jar:1.38.0] ... 22 more

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
qeepcolognecommented, Jan 11, 2021

I retry the request for the last 10 errors with postman by hand. All of them produce the error i posted above. Then i called the backend send method via jconsole for the same fcm token and i got correct FirebaseMessagingException with MessagingErrorCode.UNREGISTERED in ex.getMessagingErrorCode(). In summary: i cannot reproduce the problem on our staging (with the tokens and content from live / we use the same firebase account for live&staging). Number of errors on live is increasing, but that’s logical, because we do not remove the unregistered tokens because of the error above and send more messages to these users.

After more investigation i found out, that error went away after server restart (and coming back after some hours). So i think it is related to http-client and or internal connection pool or connection reuse in the sdk. That is also explains, why i could never reproduce it on staging or with postman.

0reactions
roma2341commented, Oct 26, 2022

We have the same error but with Gmail: Caused by: java.lang.IllegalArgumentException: expected collection or array type but got java.util.List<com.google.api.services.calendar.model.CalendarListEntry> And we can’t load emails until our app restarted. Problem appears ~ every two weeks…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - unexpected/unparsable response - - Bountysource
When calling FirebaseMessaging.getInstance().send(message), sometimes it failes with strange exception. Sometimes no errors for a day, sometime hundreds or ...
Read more >
Error while parsing JSON Response in REST API Post call
I have copied and pasted the REST Request and Response JSON definitions into the ... Parsing '': Unexpected character encountered while parsing value:...
Read more >
Why is this string unparseable? - Stack Overflow
So why is there an unexpected end of input? I'm assuming it has something to do with the backslashes, but I can't figure...
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
What went wrong? JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect...
Read more >
Error codes for the Amazon EC2 API - AWS Documentation
These errors are accompanied by a 400-series HTTP response code. ... InvalidManifest, The specified AMI has an unparsable manifest, or you may not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found