docs: SDK OpenAPI spec no longer documents the 2000-character trait value limit
#7,995 建立於 2026年7月13日
倉庫指標
- Star
- (3,475 star)
- PR 合併指標
- (平均合併 3天 7小時) (30 天內合併 157 個 PR)
描述
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
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