-
Notifications
You must be signed in to change notification settings - Fork 470
Description
How are you running Flagsmith
- Self Hosted with Docker
- Self Hosted with Kubernetes
- SaaS at flagsmith.com
- Some other way (add details in description below)
Describe the bug
Hello,
I don't know if it's a bug or a misunderstanding on my part, but I've recently disabled the "Persist traits when using client-side SDK keys" option for which the tooltip says : "If enabled, Flagsmith will persist any non-transient traits sent by SDKs using client-side keys when remotely evaluating flags."
My understanding was that the traits would still be used for evaluating the segments, but would not get persisted to the database.
However, on my system (running the latest version of flagsmith at the time of writing this issue), my traits are not used in the evaluation and I simply get the environment default values.
I think this is related to https://github.com/Flagsmith/flagsmith/blob/main/api/environments/sdk/serializers.py#L193-L197
Where we should return instead of an empty list, all traits as transient.
something like:
def validate_traits(self, traits: typing.List[dict] = None): # type: ignore[no-untyped-def,type-arg,assignment]
request = self.context["request"]
if traits and not request.environment.trait_persistence_allowed(request):
for trait in traits:
trait["transient"] = True
return traits
Steps To Reproduce
- Go to environment settings / sdk settings
- turn off Persist traits when using client-side SDK keys
- call getidentity with traits
- Confirm that the traits are missing from response and flags are only env default
Expected behavior
Traits (transient or not) should be used to evaluate returned flags
Screenshots
No response