v3 notification preferences: PUT with email_cadence but no notification_channel raises KeyError (500)

Abierto Apto para principiantes
#39,221 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

  • #39241 de @mvanhorn — cerrado sin fusionar
  • #39278 de @florianaltendorfer — cerrado sin fusionar

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
66/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
backend

Línea de trabajo

Empieza con el PUT a /api/notifications/v3/configurations/ usando el payload del issue, que debería reproducir el KeyError en _prepare_update_data. Compara ese método y _log_preference_update_event con _prepare_response_data, que ya infiere email_cadence como canal, y revisa UserNotificationPreferenceUpdateAllSerializer.validate(). Está terminado cuando la solicitud se completa infiriendo el canal, o devuelve un 400 que nombra el campo. Los mantenedores deben elegir qué comportamiento quieren antes de hacer el cambio.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

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.

Lenguaje dominante
Python
Estrellas
8.2k
Forks
4.4k
Merge medio
2 d 10 h
PR fusionados (30 d)
40

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de openedx/openedx-platform

Todos los issues de openedx/openedx-platform

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.