Closed yuriyvl closed 5 years ago
Hi @yuriyvl,
Thanks for the issue report.
From looking into the issue, it seems that you are using the jsonVariation
call to retrieve a flag that is set as a string in the LaunchDarkly UI. Versions of the Android SDK prior to 2.7.0 would not maintain a distinction between string and json flags in the local flag store, meaning that either type could be accessed through either variation call. In the 2.7.0 update, compatibility code was introduced to allow json flag values to be retrieved through the stringVariation
call, but not the other way around.
I believe when this change was made in 2.7.0, the web UI also did not give the option of selecting a flag's variation type manually. What this meant was that when a flag was created through the web UI, it would automatically be created as a json flag if the variations consisted of valid json. I believe this is why compatibility code was not introduced to attempt parsing string flags as json in the jsonVariation
call.
Ultimately we intend to remove this ambiguous conversion between string and json flags in the next major release.
Can you confirm whether this flag is created as a string flag in the LaunchDarkly web UI?
Thanks, @gwhelanLD
@gwhelanLD ,
Thanks for a prompt response! That was indeed the problem. Now we just need to cleanly fix it on the back-end and upgrade.
Again, thanks for your help. @yuriyvl
This issue started happening with version 2.7.0 (version 2.6.0 works). It is still present in the latest 2.8.3.
We are getting
java.lang.IllegalStateException: Not a JSON Object
. Here is the snippet with version 2.6.0 that works:And here is the snippet with 2.7.0+:
Note how the jsonElement is wrapped in additional "".
The exception happens when we try to extract jsonObject from jsonElement:
The actual exception is: