How are you running Flagsmith
Describe the bug
The public SDK OpenAPI spec (sdk/openapi.yaml) advertises trait_value as an unconstrained string, but the API still rejects string trait values longer than 2000 characters.
The limit is enforced at runtime in api/environments/identities/traits/fields.py:27 via TRAIT_STRING_VALUE_MAX_LENGTH = 2000:
Value string is too long. Must be less than 2000 character
The spec previously documented it. trait_value.anyOf included {type: string, maxLength: 2000} — but the constraint was dropped in #6653 (flag-engine v10 upgrade, re-applied in #6741).
The trait schema now derives from flag_engine.segments.types.ContextValue (None | int | float | bool | str), which carries no length constraint, so manage.py spectacular emits a plain string.
Steps To Reproduce
- Open the sdk_v1_post_identities reference (or sdk/openapi.yaml) and check
traits[].trait_value, the string variant shows no maxLength.
- Send a trait value of 2001 characters:
curl -X POST https://edge.api.flagsmith.com/api/v1/identities/ \
-H 'X-Environment-Key: <client-side key>' \
-H 'Content-Type: application/json' \
-d "{\"identifier\": \"repro-user\", \"traits\": [{\"trait_key\": \"long\", \"trait_value\": \"$(printf 'a%.0s' {1..2001})\"}]}"
- The API responds 400 Bad Request:
{"traits": [{"trait_value": ["Value string is too long. Must be less than 2000 character"]}]}
- Per the published spec, this request is valid
Expected behavior
TraitInput.trait_value and Trait.trait_value in the spec should document maxLength: 2000 on the string variant, matching what the API enforces.
Screenshots
No response
How are you running Flagsmith
Describe the bug
The public SDK OpenAPI spec (sdk/openapi.yaml) advertises trait_value as an unconstrained string, but the API still rejects string trait values longer than 2000 characters.
The limit is enforced at runtime in api/environments/identities/traits/fields.py:27 via
TRAIT_STRING_VALUE_MAX_LENGTH = 2000:Value string is too long. Must be less than 2000 character
The spec previously documented it.
trait_value.anyOfincluded{type: string, maxLength: 2000}— but the constraint was dropped in #6653 (flag-engine v10 upgrade, re-applied in #6741).The trait schema now derives from
flag_engine.segments.types.ContextValue (None | int | float | bool | str), which carries no length constraint, so manage.py spectacular emits a plain string.Steps To Reproduce
traits[].trait_value, the string variant shows no maxLength.{"traits": [{"trait_value": ["Value string is too long. Must be less than 2000 character"]}]}Expected behavior
TraitInput.trait_valueandTrait.trait_valuein the spec should documentmaxLength: 2000on the string variant, matching what the API enforces.Screenshots
No response