Features read from file cannot be cast to Feature
pschmidt88 opened this issue · 2 comments
Hello,
I think I found a bug in the current feature storage and repository implementation:
When features are read from the backup/cache file and were not (yet) fetched from the server, every feature evaluates to false/disabled.
This is because, when features are read from file, they are decoded to a generic map[string]interface{}
structure,
because the type of the data holding variable is a map[string]interface{}
and the decoder doesn't know to which type it should
decode the json to.
Lines 37 to 41 in 108a79f
Lines 58 to 68 in 108a79f
The repository then tries to cast this generic structure to a Feature
struct (L146), which does not work, eventually returning a nil
value although a valid feature exists.
unleash-client-go/repository.go
Lines 141 to 151 in 108a79f
To reproduce this behavior, you can:
- Create a client with a custom backup path
- Let the client persist features fetched from the server into the schema json file
- Stop the server
- Restart the client and let it read the features from the file
- Query an enabled toggle
The feature toggle will evaluate to false
Is there a reason why data
in defaultStorage
is of type map[string]interface{}
and not map[string]api.Feature
?
This was fixed in #83