v3 notification preferences: PUT with email_cadence but no notification_channel raises KeyError (500)
维护者通常 1 天内回复
评估
调研方向
从使用 issue 中的 payload 对 /api/notifications/v3/configurations/ 发起 PUT 请求开始,这应该能复现 _prepare_update_data 中的 KeyError。将该方法和 _log_preference_update_event 与 _prepare_response_data 进行比较,后者已经将 email_cadence 推断为渠道,并检查 UserNotificationPreferenceUpdateAllSerializer.validate()。完成的标准是:请求推断出渠道并成功,或返回指明字段的 400。维护者必须在修改前选定所需的行为。
由索引模型根据 Issue 内容生成。
描述
PUT /api/notifications/v3/configurations/ with an e-mail cadence and no notification_channel:
{"notification_app": "discussion", "notification_type": "grouped_notification",
"email_cadence": "Weekly"}
passes validation, then fails in the view:
KeyError: 'notification_channel'
in _prepare_update_data
Internal Server Error: /api/notifications/v3/configurations/
With "notification_channel": "email_cadence" added, the same update succeeds (200). The account MFE always sends the channel, so this is only reachable through the API.
Cause: UserNotificationPreferenceUpdateAllSerializer.validate() deliberately lets email_cadence stand in for the channel (it only requires notification_channel when there is no email_cadence), and NotificationPreferencesViewV3._prepare_response_data infers channel = 'email_cadence' in that case. But _prepare_update_data and _log_preference_update_event both read validated_data['notification_channel'] directly, so the request 500s before the update is applied.
Expected: infer email_cadence as the channel in _prepare_update_data and _log_preference_update_event, as _prepare_response_data already does (or, if the channel is meant to be mandatory, require it in the serializer so the client gets a 400 naming the field).
Environment: Tutor main, image of 2026-09-18; code unchanged on master as of 2026-10-13. Found by the Open edX end-to-end test suite.
- 主要语言
- Python
- 星标
- 8.2k
- 派生
- 4.4k
- 平均合并
- 2 天 10 小时
- 30 天内合并 PR
- 40
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openedx/openedx-platform 的其他 Issue
-
Discussion API: missing thread returns 500 (ForumV2RequestError not mapped to ThreadNotFoundError)可能重新可做 @mbhavu2007-lang 于 16 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
openedx/openedx-platform#39225 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
openedx/openedx-platform#39169 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
openedx/openedx-platform#39084 ·
维护者通常 1 天内回复
-
难度 2/5 1 小时以内 新手友好度 82/100
openedx/openedx-platform#38792 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
openedx/openedx-platform#38544 ·
维护者通常 1 天内回复
查看 openedx/openedx-platform 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
-
难度 2/5 1-3 小时 新手友好度 76/100
btclib-org/btclib-wallet#1045 ·
维护者通常 1 天内回复
-
area-templates triage:bot-seen triage:needs-human
难度 2/5 1-3 小时 新手友好度 75/100
microsoft/aspire#22356 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
[Train] An elastic ScalingConfig(num_workers=(0, 0)) is accepted and the run waits forever可能已有人在做 @wguo7 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
ray-project/ray#68217 ·
维护者通常 2 天内回复