PATCH on a multivariate option returns 500 (KeyError: 'feature')

未关闭 适合新手
#9,119 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
api, backend

调研方向

报告指出 features/multivariate/serializers.py 第 85 行,其中 validate() 在部分更新期间引发 KeyError: 'feature'。阅读该 serializer 及其附近的测试,然后运行相关的 multivariate option API 测试。当仅包含 string_value 的 PATCH 不再返回 500,或者在不支持 PATCH 时返回明确的 400,即为完成。

由索引模型根据 Issue 内容生成。

描述

Version: self-hosted 2.295.2 (flagsmith/flagsmith:2.295.2, Docker Compose)

What happens

A partial update of a multivariate option returns HTTP 500 unless the body repeats every field:

curl -i -X PATCH -H "Authorization: Api-Key $ORG_API_KEY" -H "Content-Type: application/json" \
  "http://localhost:8000/api/v1/projects/<project>/features/<feature>/mv-options/<option>/" \
  -d '{"string_value": "green"}'
Server log
File "/app/features/multivariate/serializers.py", line 85, in validate
KeyError: 'feature'
Expected

The option's value is updated (a 400 would also be fine if PATCH isn't supported), not a 500.

Notes

validate() reads attrs["feature"], which a partial update doesn't include; self.instance.feature could be used instead. Found while building FlagLens, whose seed script works around it.

主要语言
Python
星标
9.9k
派生
658
平均合并
1 天 15 小时
30 天内合并 PR
168

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Flagsmith/flagsmith 的其他 Issue

查看 Flagsmith/flagsmith 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。