Flagsmith / flagsmith-kotlin-android-client

Kotlin based client for using Flagsmith in Android applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deserialization error when trying getFeatureFlags with identity param

armanbisembaev opened this issue · comments

Hello, thank you for this client.
We are using self-hosted flagsmith and we have faced with deserialization error:
Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $

After some code research and tests I figured out that problem is wrong JSON format or wrong deseralization model using.

This is example response from flagsmith.getFeatureFlags(identity):

[
  {
    "id": 17,
    "feature": {
      "id": 8,
      "name": "someflag",
      ...
    },
    "feature_state_value": "somevalue",
    ...
  },
  {
    "id": 18,
    "feature": {
      "id": 9,
      "name": "someflag0",
      ...
    },
    "feature_state_value": "somevalue0",
    ...
  }
]

But due to code from IdentityFlagsAndTraitsDeserializer.kt:

class IdentityFlagsAndTraitsDeserializer: ResponseDeserializable<IdentityFlagsAndTraits> {
    override fun deserialize(reader: Reader): IdentityFlagsAndTraits? {
        return Gson().fromJson(reader, IdentityFlagsAndTraits::class.java)
    }
}

This fragment of code expect a JSON string according to IdentityFlagsAndTraits model

data class IdentityFlagsAndTraits(
    val flags: ArrayList<Flag>,
    val traits: ArrayList<Trait>
)

Could you suggest please, what are our points?

gz#359

Hi @armanbisembaev - just wanted to know if you fixed this issue? I saw you closed it?

Hi @armanbisembaev - just wanted to know if you fixed this issue? I saw you closed it?

Hello, it seems like PR #9 is solving this issue.
But we decided to do direct http requests to self-hosted flagsmith for now. Due to deadlines.