Creating a segment with a PERCENTAGE_SPLIT condition and no `property` returns 500 (KeyError: 'property')
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
Rechercherichtung
Beginne in api/segments/serializers.py bei SegmentSerializer._get_clean_rules_and_conditions und prüfe dann die Validierung der Bedingungen und die Behandlung der prozentualen Aufteilung in flag_engine/segments/evaluator.py. Reproduziere die Admin API-Anfrage aus dem Issue und prüfe die vorhandenen Tests für den Segment-Serializer. Erledigt ist es, wenn eine prozentuale Aufteilung ohne property erstellt werden kann und weiterhin den Identitätsschlüssel verwendet, während die Validierung der übrigen Bedingungen weiterhin abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
Creating a segment through the Admin API with a PERCENTAGE_SPLIT condition and no property fails with a 500.
The engine supports a split with no property: it hashes the identity key. Its own comment says, "Currently, the only supported condition with a blank property is percentage split" (flag_engine/segments/evaluator.py). But SegmentSerializer._get_clean_rules_and_conditions reads condition["property"] directly (api/segments/serializers.py, line 325 on main), which raises KeyError: 'property'.
Sending "property": "" or "property": null instead is rejected with a 400 ("property": ["This field may not be blank."]). So the API can't create a plain percentage split. The new CLI's flagsmith segment create --rules … gets the same 500.
Seen on Flagsmith 2.295.2 (Docker). The same code is on main as of 28 Nov 2026.
Steps To Reproduce
curl -X POST "$FLAGSMITH/api/v1/projects/$PROJECT/segments/" \
-H "Authorization: Api-Key $ADMIN_KEY" -H "Content-Type: application/json" \
-d '{"name":"Half of users","project":'"$PROJECT"',"rules":[{"type":"ALL","rules":[{"type":"ANY","rules":[],"conditions":[{"operator":"PERCENTAGE_SPLIT","value":"50"}]}],"conditions":[]}]}'
The response is HTTP 500, and the API log shows:
File "/app/segments/serializers.py", line 325, in _get_clean_rules_and_conditions
"property": condition["property"],
KeyError: 'property'
With "property": "" or null instead, the response is HTTP 400: This field may not be blank.
Expected behavior
The segment is created as a percentage split over the identity key, which the engine already supports. Perhaps condition.get("property") in _get_clean_rules_and_conditions, with a blank property allowed for PERCENTAGE_SPLIT during validation.
Workaround: "property": "$.identity.key" creates a split that the engine hashes the same way.
Screenshots
n/a
Found while building flagsmith-toolbar, a developer toolbar for the Flagsmith JS SDK.
- Vorherrschende Sprache
- Python
- Sterne
- 9.9k
- Forks
- 658
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 171
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Flagsmith/flagsmith
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Flagsmith/flagsmith#9119 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Fix Button Alignment in SDK Installation SectionEvtl. vergeben @manueldezman hat das vor 4 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Flagsmith/flagsmith#9056 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Cloud Python warehouse snippet omits the import needed by its short-lived-job guidanceEvtl. vergeben @jcd1991 hat das vor 5 Tagen übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
Flagsmith/flagsmith#9045 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Expose whether an organisation is blocked for API usageEvtl. vergeben @PiUnknown hat das vor 39 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Flagsmith/flagsmith#8773 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
influx_query_manager doesn't catch ApiException, so Influx error responses 500Evtl. vergeben @SAY-5 hat das vor 14 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Flagsmith/flagsmith#8510 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in Flagsmith/flagsmith
Ähnliche Issues
-
documentation good first issue help wanted
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
-
documentation good first issue help wanted
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
-
documentation good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
-
[Suggestion]: AgentermOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
collabnix/awesome-mcp-lists#490 ·
Maintainer antworten meist innerhalb von 2 Tagen