Flagsmith / Flagsmith/flagsmith

Edge API returns 400 with no message if `allow_client_traits` is `false`

Open
#5,397 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.6k
Forks
567
Avg merge
1d 14h
Merged PRs (30d)
124

Description

### How are you running Flagsmith

- [ ] Self Hosted with Docker
- [ ] Self Hosted with Kubernetes
- [x] 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_

Contributor guide

Open the contributing guide

Research direction

Start by comparing the Edge API and Core API POST identity endpoints shown in the reproduction, focusing on how the 400 response is serialized when allow_client_traits is false. Confirm the Edge response includes the same error message as the Core response, then rerun both curl requests to verify that no 4xx response is empty.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.