Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(feature flags): Guard for None values when comparing person Properties #129

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

Phanatic
Copy link
Contributor

Problem

Porting over the fix from posthog-node to posthog-python : PostHog/posthog-js-lite#249

The current behavior of stringifying None values to compare with operators can lead to invalid results in local evaluation.

This causes local evaluation to return true, while the /decide API does the right thing and returns false for undefined values in these properties.

Customer reported that local evaluation always evaluates a condition to true, when it should evaluate to false.
The conditions in question are :

[
    {
        "key": "latestBuildVersion",
        "type": "person",
        "value": ".+",
        "operator": "regex"
    },
    {
        "key": "latestBuildVersionMajor",
        "type": "person",
        "value": "23",
        "operator": "gt"
    },
    {
        "key": "latestBuildVersionMinor",
        "type": "person",
        "value": "31",
        "operator": "gt"
    },
    {
        "key": "latestBuildVersionPatch",
        "type": "person",
        "value": "0",
        "operator": "gt"
    }
]

And the person properties passed into local evaluation are :

{
    "personProperties": {
        "latestBuildVersion": None,
        "latestBuildVersionMajor": None,
        "latestBuildVersionMinor": None,
        "latestBuildVersionPatch": None
    }
}

Since we stringify all of the None values, the above call returns true when it should return false because the property values are undefined and not the string None.

Changes

Add a NONE_VALUES_ALLOWED_OPERATORS array of operators that allow NONE values which is just is_not right now . Any other operator will fail if the overrideValue is NONE

@Phanatic Phanatic requested a review from a team August 21, 2024 15:59
Copy link

@dmarticus dmarticus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this need a version bump as well?

@Phanatic Phanatic merged commit b83d544 into master Aug 21, 2024
2 checks passed
@Phanatic Phanatic deleted the null-value-local-evaluation branch August 21, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants