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

Fatal Exception: kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Expected start of the object #142

Open
beinghassandar1 opened this issue Sep 20, 2024 · 12 comments

Comments

@beinghassandar1
Copy link

beinghassandar1 commented Sep 20, 2024

Hey guys, we are getting this crash on Android 13.

Can you guys please tell us why growth book is trying to deserialize <!DOCTYPE html><html lang="pt" from the backend instead of the actual json for features?

Lib Versions:

lib-growthbook = "1.1.61"
lib-growthbook-dispatcher = "1.0.0"
lib-growthbook = { module = "io.growthbook.sdk:GrowthBook", version.ref = "lib-growthbook" }
lib-growthbook-dispatcher = { module = "io.growthbook.sdk:NetworkDispatcherOkHttp", version.ref = "lib-growthbook-dispatcher" }

Initialization

  instance = GBSDKBuilder(
            apiKey = configHelper.getGrowthBookApiKey(),
            hostURL = configHelper.getGrowthBookUrl(),
            trackingCallback = { gbExperiment, gbExperimentResult ->
                Logging.d("$LOG_TAG - trackingCallback: Experiment Id: " + gbExperiment.key)
            },
            networkDispatcher = GBNetworkDispatcherOkHttp(httpClient),
            attributes = attributesMap,
        ).setRefreshHandler { isRefreshed, error ->
        }.setFeatureUsageCallback(featureUsageCallback = { featureKey, gbFeatureResult ->
        }).initialize()
Fatal Exception: kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Expected start of the object '{', but had '<' instead at path: $
JSON input: <!DOCTYPE html><html lang="pt".....
       at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
       at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail(AbstractJsonLexer.kt:598)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$default(AbstractJsonLexer.kt:596)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json(AbstractJsonLexer.kt:233)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json$default(AbstractJsonLexer.kt:228)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.unexpectedToken(AbstractJsonLexer.kt:225)
       at kotlinx.serialization.json.internal.StringJsonLexer.consumeNextToken(StringJsonLexer.kt:74)
       at kotlinx.serialization.json.internal.StreamingJsonDecoder.beginStructure(StreamingJsonDecoder.kt:102)
       at com.sdk.growthbook.features.FeaturesDataModel$$serializer.deserialize(FeaturesDataModel.kt:10)
       at com.sdk.growthbook.features.FeaturesDataModel$$serializer.deserialize(FeaturesDataModel.kt:10)
       at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
       at kotlinx.serialization.json.Json.decodeFromString(Json.kt:107)
       at com.sdk.growthbook.features.FeaturesDataSource$fetchFeatures$1.invoke(FeaturesDataSource.kt:42)
       at com.sdk.growthbook.features.FeaturesDataSource$fetchFeatures$1.invoke(FeaturesDataSource.kt:40)
       at com.sdk.growthbook.network.GBNetworkDispatcherOkHttp$consumeGETRequest$1$1.onResponse(GBNetworkDispatcherOkHttp.kt:61)
       at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
       at java.lang.Thread.run(Thread.java:1012)
Fatal Exception: kotlinx.serialization.json.internal.JsonDecodingException
Expected start of the object '{', but had 'EOF' instead at path: $ JSON input:
kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException (JsonExceptions.kt:24)
kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException (JsonExceptions.kt:32)
kotlinx.serialization.json.internal.AbstractJsonLexer.fail (AbstractJsonLexer.kt:598)
kotlinx.serialization.json.internal.AbstractJsonLexer.fail$default (AbstractJsonLexer.kt:596)
kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json (AbstractJsonLexer.kt:233)
kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json$default (AbstractJsonLexer.kt:228)
kotlinx.serialization.json.internal.AbstractJsonLexer.unexpectedToken (AbstractJsonLexer.kt:225)
kotlinx.serialization.json.internal.StringJsonLexer.consumeNextToken (StringJsonLexer.kt:77)
kotlinx.serialization.json.internal.StreamingJsonDecoder.beginStructure (StreamingJsonDecoder.kt:102)
com.sdk.growthbook.features.FeaturesDataModel$$serializer.deserialize (FeaturesDataModel.kt:10)
com.sdk.growthbook.features.FeaturesDataModel$$serializer.deserialize (FeaturesDataModel.kt:10)
kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue (StreamingJsonDecoder.kt:69)
kotlinx.serialization.json.Json.decodeFromString (Json.kt:107)
com.sdk.growthbook.features.FeaturesDataSource$fetchFeatures$1.invoke (FeaturesDataSource.kt:42)
com.sdk.growthbook.features.FeaturesDataSource$fetchFeatures$1.invoke (FeaturesDataSource.kt:40)
com.sdk.growthbook.network.GBNetworkDispatcherOkHttp$consumeGETRequest$1$1.onResponse (GBNetworkDispatcherOkHttp.kt:61)
okhttp3.internal.connection.RealCall$AsyncCall.run (RealCall.kt:519)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
java.lang.Thread.run (Thread.java:1015)
@madhuchavva
Copy link

@beinghassandar1 Do you mind checking if you're using the right endpoint/config ?

@beinghassandar1
Copy link
Author

We are using our self hosted api endpoint. 99% of the users get correct data... Few users are getting Json from the same endpoint.

@vazarkevych
Copy link
Collaborator

Hi, @beinghassandar1. We will check that and get back to you asap.

@beinghassandar1
Copy link
Author

Thank you. Just fyi, we are seeing more crash reports for other Android versions too. Like Android 9, 11, 12, 13, 14.
All of them are either of the 2 crashes in the message above.

@vazarkevych
Copy link
Collaborator

Thank you for the detailed information. It will help us fix that.

@vazarkevych
Copy link
Collaborator

We are using our self hosted api endpoint. 99% of the users get correct data... Few users are getting Json from the same endpoint.

But what actually highlights that 1 percent with not right information. Maybe some version or some properties?

@beinghassandar1
Copy link
Author

Hhmm, hard to say. They are all on the latest build as we have recently released the new version with Growthbook sdk implementation.

@beinghassandar1
Copy link
Author

We are also getting more reports now but the crash is always something to do with wrong json.

    Fatal Exception: kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Expected start of the object '{', but had '<' instead at path: $
JSON input: <!DOCTYPE html><html><noscript.....
       at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
       at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail(AbstractJsonLexer.kt:598)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$default(AbstractJsonLexer.kt:596)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json(AbstractJsonLexer.kt:233)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json$default(AbstractJsonLexer.kt:228)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.unexpectedToken(AbstractJsonLexer.kt:225)
       at kotlinx.serialization.json.internal.StringJsonLexer.consumeNextToken(StringJsonLexer.kt:74)
       at kotlinx.serialization.json.internal.StreamingJsonDecoder.beginStructure(StreamingJsonDecoder.kt:102)
       at com.sdk.growthbook.features.FeaturesDataModel$$serializer.deserialize(FeaturesDataModel.kt:10)
       at com.sdk.growthbook.features.FeaturesDataModel$$serializer.deserialize(FeaturesDataModel.kt:10)
       at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
       at kotlinx.serialization.json.Json.decodeFromString(Json.kt:107)
       at com.sdk.growthbook.features.FeaturesDataSource$fetchFeatures$1.invoke(FeaturesDataSource.kt:42)
       at com.sdk.growthbook.features.FeaturesDataSource$fetchFeatures$1.invoke(FeaturesDataSource.kt:40)
       at com.sdk.growthbook.network.GBNetworkDispatcherOkHttp$consumeGETRequest$1$1.onResponse(GBNetworkDispatcherOkHttp.kt:61)
       at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
       at java.lang.Thread.run(Thread.java:1012)
        

@madhuchavva
Copy link

@beinghassandar1 Is there a pattern you see on these crash errors? the 1% users are consistently getting this error? if it consistent, is there a way for you to replicate this error?

@vazarkevych
Copy link
Collaborator

Hi, @beinghassandar1 . After what steps did these users receive that, and what options did the user enable?

@beinghassandar1
Copy link
Author

beinghassandar1 commented Oct 1, 2024

Hey, When user logins and we initialize the sdk, we see a crash from there users.
Its not even 1% now. Its more than that. I saw 450+ crashes for 116 users. All are for the same reason. The json is not valid.

Also, I got a new crash log.

ourserver_url = the url of our own hosting server

    Fatal Exception: kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Expected start of the object '{', but had 'r' instead at path: $
JSON input: relay failed to <ourserver_url>:3100
       at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
       at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail(AbstractJsonLexer.kt:598)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$default(AbstractJsonLexer.kt:596)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json(AbstractJsonLexer.kt:233)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json$default(AbstractJsonLexer.kt:228)
       at kotlinx.serialization.json.internal.AbstractJsonLexer.unexpectedToken(AbstractJsonLexer.kt:225)
       at kotlinx.serialization.json.internal.StringJsonLexer.consumeNextToken(StringJsonLexer.kt:74)
       at kotlinx.serialization.json.internal.StreamingJsonDecoder.beginStructure(StreamingJsonDecoder.kt:102)
       at com.sdk.growthbook.features.FeaturesDataModel$$serializer.deserialize(FeaturesDataModel.kt:10)
       at com.sdk.growthbook.features.FeaturesDataModel$$serializer.deserialize(FeaturesDataModel.kt:10)
       at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
       at kotlinx.serialization.json.Json.decodeFromString(Json.kt:107)
       at com.sdk.growthbook.features.FeaturesDataSource$fetchFeatures$1.invoke(FeaturesDataSource.kt:42)
       at com.sdk.growthbook.features.FeaturesDataSource$fetchFeatures$1.invoke(FeaturesDataSource.kt:40)
       at com.sdk.growthbook.network.GBNetworkDispatcherOkHttp$consumeGETRequest$1$1.onResponse(GBNetworkDispatcherOkHttp.kt:61)
       at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
       at java.lang.Thread.run(Thread.java:1012)
        

@vazarkevych
Copy link
Collaborator

Hi, @beinghassandar1. Thank you for information, we will check that.

vazarkevych pushed a commit that referenced this issue Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants