Django exceptions reach DRF as 500
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- backend-api-design
Línea de trabajo
Start with contentcuration/contentcuration/viewsets/base.py and the serialize_object behavior linked in the issue, then read the related DRF views and the exception handler strategy in #6387. Add regression tests for each input listed in Context and verify malformed detail-route pks return 404, invalid parameters and submission states return 400, and Django ObjectDoesNotExist returns 404.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Overview
Some code raises Django's ValidationError, ObjectDoesNotExist or FieldError inside DRF views. DRF converts only its own exceptions, Http404 and PermissionDenied, so these return 500. BaseValuesViewset.serialize_object also crashes on some malformed pks before it can return its 404.
Complexity: Medium
Target branch: hotfixes
Context
All inputs below were reproduced:
BaseValuesViewset.serialize_object:- On a model with an integer pk,
GET /api/assessmentitem/abcraisesUnboundLocalError, because.filter()fails beforequerysetis assigned. Kolibri fixed this in learningequality/kolibri@eeb4c8207e. - On
SavedSearch, whose pk is a DjangoUUIDField,GET /api/search/saved-search/abcraises DjangoValidationError, which isn't in the caught tuple. - Affected detail routes:
assessmentitem,user,admin-users,bookmark,channeluser,communitylibrary_submission,admin_communitylibrary_submission,saved-search.
- On a model with an integer pk,
ChannelUserViewSet:GET /api/channeluser/<id>without?channel=raisesFieldError: Cannot resolve keyword 'can_edit'.can_editandcan_viewexist only once the channel filter has annotated them.ContentNodeTreeViewset.validate_and_return_params:depth=3,depth=abc,next__gt=-1andnext__gt=abcraise DjangoValidationErroron the anonymous public tree endpoint. Kolibri has the same code (learningequality/kolibri#15835).resolvecallsCommunityLibrarySubmission.save, which raises DjangoValidationErrorwhen the author is no longer a channel editor or the channel has since become public.
The Change
serialize_objectshould follow Kolibri's fix and also treat DjangoValidationErroras not found.channeluserretrieve without?channel=should respond as the list route does. Each other site should return 400 instead of 500.- The custom
EXCEPTION_HANDLERfrom the strategy in #6387 lands in this issue.
Acceptance Criteria
General
- Each detail route listed in Context returns 404 for a malformed pk.
-
channeluserretrieve without?channel=gets the same response as the list route without?channel=. - Invalid
depthandnext__gtvalues return 400. -
resolvereturns 400 with the validation message for the two submission states in Context. - Django
ValidationErrorraised in any DRF view returns 400, andObjectDoesNotExistreturns 404.
Testing
- Each input in Context has a regression test.
AI usage
I scoped the audit and chose the validation strategy in #6387. Claude Code found and reproduced these failures and drafted this issue.
- Lenguaje dominante
- Python
- Estrellas
- 212
- Forks
- 321
- Merge medio
- 1 d 7 h
- PR fusionados (30 d)
- 14
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de learningequality/studio
-
Community library status changes don't update `date_updated`Posiblemente ocupada @ArpitaSamanta10 la tomó hoy. Abiertocommunity-contribution-in-progress DEV: backend good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
learningequality/studio#6414 · 8 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
DEV: backend
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
learningequality/studio#6410 ·
Los mantenedores suelen responder en 1 día
-
DEV: backend
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
learningequality/studio#6409 ·
Los mantenedores suelen responder en 1 día
-
DEV: backend
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
learningequality/studio#6407 ·
Los mantenedores suelen responder en 1 día
-
Stripe webhook accepts events when no webhook secret is configuredPosiblemente ocupada @adibmbrk la tomó hoy. Abiertocommunity-contribution-in-progress DEV: backend good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
learningequality/studio#6404 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de learningequality/studio
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
Reference check: findingsAbiertoaudit-reference-check
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
screenrec.com stopped workingAbiertosite-bug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
canonical/paas-charm#407 · 1 comentario ·
Los mantenedores suelen responder en 5 días