Creating a segment with a PERCENTAGE_SPLIT condition and no `property` returns 500 (KeyError: 'property')
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 api/segments/serializers.py 中的 SegmentSerializer._get_clean_rules_and_conditions 开始,然后检查 flag_engine/segments/evaluator.py 中的条件验证和百分比拆分处理。重现 issue 中的 Admin API 请求,并检查现有的分段序列化器测试。当不带 property 也能创建百分比拆分,且仍使用身份键,同时其他条件的验证仍有测试覆盖时,即为完成。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 9.9k
- 派生
- 658
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 171
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Flagsmith/flagsmith 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
Flagsmith/flagsmith#9119 · 1 条评论 ·
维护者通常 1 天内回复
-
Fix Button Alignment in SDK Installation Section可能已有人在做 @manueldezman 于 4 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 62/100
Flagsmith/flagsmith#9056 · 2 条评论 ·
维护者通常 1 天内回复
-
Cloud Python warehouse snippet omits the import needed by its short-lived-job guidance可能已有人在做 @jcd1991 于 5 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 75/100
Flagsmith/flagsmith#9045 · 1 条评论 ·
维护者通常 1 天内回复
-
Expose whether an organisation is blocked for API usage可能已有人在做 @PiUnknown 于 39 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
Flagsmith/flagsmith#8773 · 1 条评论 ·
维护者通常 1 天内回复
-
influx_query_manager doesn't catch ApiException, so Influx error responses 500可能已有人在做 @SAY-5 于 14 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
Flagsmith/flagsmith#8510 · 1 条评论 ·
维护者通常 1 天内回复
查看 Flagsmith/flagsmith 的全部 Issue
相似的 Issue
-
documentation good first issue help wanted
难度 1/5 1 小时以内 新手友好度 90/100
-
documentation good first issue help wanted
难度 1/5 1 小时以内 新手友好度 88/100
-
documentation good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 72/100
collabnix/awesome-mcp-lists#490 ·
维护者通常 2 天内回复