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

Unable to identify user with a trait that has the value "Nan" #183

Closed
1 of 4 tasks
matthewelwell opened this issue Jul 11, 2023 · 1 comment · Fixed by #184
Closed
1 of 4 tasks

Unable to identify user with a trait that has the value "Nan" #183

matthewelwell opened this issue Jul 11, 2023 · 1 comment · Fixed by #184
Assignees
Labels
bug Something isn't working

Comments

@matthewelwell
Copy link
Contributor

Describe the bug

Setting a trait to a string of "Nan" when identifying a user causes a 502 error in the Edge API and will cause the detail view of the identity to fail to load in the Flagsmith dashboard.

To Reproduce

curl --location 'https://edge.api.flagsmith.com/api/v1/identities' \
--header 'Content-Type: application/json' \
--header 'X-Environment-Key: <ENV_KEY>' \
--data '{
    "identifier": "identity",
    "traits": [
        {
            "trait_key": "my_trait",
            "trait_value": "Nan"
        }
    ]
}'

Expected behavior

  1. The trait is stored as a string and a successful response is returned from the Edge API
  2. The identity detail page loads in the Flagsmith dashboard and shows the trait as a string

Screenshots

N/a

How are you running Flagsmith?

  • Self Hosted with Docker
  • Self Hosted with Kubernetes
  • SaaS at flagsmith.com
  • Some other way

Additional context

A quick fix here is to set the trait value to e.g. "Nan_"

@matthewelwell matthewelwell added the bug Something isn't working label Jul 11, 2023
@matthewelwell matthewelwell self-assigned this Jul 11, 2023
@matthewelwell
Copy link
Contributor Author

matthewelwell commented Jul 11, 2023

Seems like this is some very odd behaviour from pydantic. Here is a minimal script to reproduce the issue:

import typing
from pydantic import BaseModel


class MyModel(BaseModel):
    foo: typing.Union[float, str]


o = MyModel.parse_obj({"foo": "Nan"})

assert o.foo == "Nan"

This will throw an AssertionError

@matthewelwell matthewelwell transferred this issue from Flagsmith/flagsmith Jul 11, 2023
@matthewelwell matthewelwell linked a pull request Jul 11, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant