growthbook/growthbook-kotlin

Bug: Choose wrong default value if attribute does not exist

Closed this issue · 4 comments

The SDK get value from condition if condition field does not exist into attributes.
Growthbook response:

{
 "defaultValue": "Default value",
 "rules": [
   {
     "condition": {
       "country": "IN"
     },
     "force": "Default value for country:IN"
   },
   {
     "condition": {
       "brand": "KZ"
     },
     "force": "Default value for brand:KZ"
  }
 ]
}

User attributes:

{"brand":"KZ"}

Expected result
Feature value is Default value for brand:KZ
Actual result
Feature value is Default value for country:IN

Can you approve it is a bug ?

jdorn commented

Yes, this looks like a bug. There is a test case for something similar already - https://github.com/growthbook/growthbook-kotlin/blob/main/GrowthBook/src/commonTest/kotlin/com/sdk/growthbook/tests/GBTestCases.kt#L394

Can you add an additional test case that reproduces your issue?

Yep, I will create a PR with my unit test.

I fix the issue into #17 .

Closed the issue as it is already resolved and merged in #17.