amplitude / experiment-android-client

MIT License
4 stars 2 forks source link

JsonDecodingException #45

Closed brianwernick closed 11 months ago

brianwernick commented 11 months ago

We are currently seeing an intermittent crash when the SDK is fetching flags in 1.11.1

Information

Stack Trace
Fatal Exception: kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Expected start of the array '[', but had 'c' instead at path: $
JSON input: connection failure
       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:100)
       at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:29)
       at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
       at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:70)
       at kotlinx.serialization.json.Json.decodeFromString(Json.kt:107)
       at com.amplitude.experiment.SdkFlagApi$getFlags$2.onResponse(FlagApi.kt:80)

In a few of the crashes we see ...Expected start of the array '[', but had 'i' ('i' instead of 'c')

tyiuhc commented 11 months ago

@brianwernick, many thanks for raising this issue. v1.11.3 will now catch this SerializationException from flag fetches. Please let us know if the new release works for you as expected.

brianwernick commented 11 months ago

Awesome, thanks @tyiuhc. We'll update the version and let you know if we still see the crashes

brianwernick commented 11 months ago

We haven't seen any more crashes from this since we've updated, thanks again!