Flagsmith/flagsmith

docs: SDK OpenAPI spec no longer documents the 2000-character trait value limit

Open

#7.995 aberto em 13 de jul. de 2026

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)Python (264 forks)batch import
good first issue

Métricas do repositório

Stars
 (3.475 stars)
Métricas de merge de PR
 (Mesclagem média 3d 7h) (157 fundiu PRs em 30d)

Description

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

  1. Open the sdk_v1_post_identities reference (or sdk/openapi.yaml) and check traits[].trait_value, the string variant shows no maxLength.
  2. 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})\"}]}"
  1. The API responds 400 Bad Request:

{"traits": [{"trait_value": ["Value string is too long. Must be less than 2000 character"]}]}

  1. 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

Guia do colaborador