Unleash / unleash-client-node

Unleash client SDK for Node.js
https://docs.getunleash.io
Apache License 2.0
210 stars 71 forks source link

fix: handle context fields as string #628

Closed nunogois closed 2 months ago

nunogois commented 2 months ago

The Node SDK accepts context fields of any type and internally assumes they are strings without converting them. This means that e.g. the IN operator returns false for non-string values when we would otherwise expect it to return true.

Taking a strategy like test IN 1337 as an example:

This change makes it so we convert context values to string, using .toString() in our context value resolver. The result is that both of these examples now return ✅ TRUE.

I think this is a positive change overall since it should not break any existing intended behavior and internally we're assuming the context values are strings anyways, even if they aren't.