Skip to content

Edge API returns 400 with no message if allow_client_traits is false #5397

Open
@rolodato

Description

@rolodato

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

See reproduction steps.

Steps To Reproduce

curl --request POST \
  --url https://edge.api.flagsmith.com/api/v1/identities/ \
  --header 'X-Environment-Key: eSxMFuFLTYjRz6enMdLSBY' \
  --header 'content-type: application/json' \
  --data '{
  "identifier": "user-123",
  "traits": [
    {
      "trait_key": "foo",
      "trait_value": true,
      "transient": true
    }
  ]
}
'

returns a 400 with no error message if the environment has allow_client_traits: false. Calling the Core API directly does return an error message:

❯ curl --request POST \
        --url https://api.flagsmith.com/api/v1/identities/ \
        --header 'X-Environment-Key: eSxMFuFLTYjRz6enMdLSBY' \
        --header 'content-type: application/json' \
        --data '{
    "identifier": "user-123",
    "traits": [
      {
        "trait_key": "foo",
        "trait_value": true,
        "transient": true
      }
    ]
  }
  '
{"traits":["Setting traits not allowed with client key."]}

Expected behavior

Return the same error messages for Core and Edge API requests; do not return 4xx error responses with no error messages.

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions