Return 4xx instead of 500 for malformed API requests
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
Direzione di ricerca
This umbrella issue covers malformed input across DRF viewsets, /api/sync/, plain Django views, kolibri_public, and search; it names shared patterns and regression tests but leaves the individual root causes to sub-issues. Start by checking whether a scoped sub-issue exists, then read its cited view or serializer and reproduce the malformed request in a regression test. Done means that input returns an appropriate 400 or 404, with a test covering it; the issue says contributions are not open here.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Studio's API returns HTTP 500 for many malformed requests: a body with the wrong JSON shape, a query parameter of the wrong type, a value out of range, or a malformed id. In every case the request is the client's error and should get a 400 or 404 that says what is wrong. An audit of every endpoint found the remaining cases and grouped them by root cause. Each sub-issue fixes one root cause wherever it occurs, using the validation pattern set out below.
Scope
- Included: validation of request input (body, query params, URL kwargs) across DRF viewsets,
/api/sync/, plain Django views, and the publickolibri_publicandsearchAPIs. - Included: sync change handlers that error on malformed changes instead of returning a validation error for that change.
- Excluded: the
/api/internal/*endpoints used by ricecooker, which are to be deprecated and removed in favour of the sync endpoint. - Excluded: permission checks and data-integrity bugs, which have their own issues.
Guidance
- Target
hotfixes. - Each fix needs a regression test that sends the malformed input and asserts the 4xx. In tests, the DRF test client re-raises view exceptions, so the current behaviour shows up as an exception rather than a 500 status.
Strategy
- Every request body is validated by a DRF serializer with
is_valid(raise_exception=True). Plain Django views that parserequest.bodybecome DRF@api_viewviews. - Every query parameter is a typed django-filter filter on the viewset's FilterSet, such as
UUIDFilter/UUIDInFilterfromcontentcuration/contentcuration/viewsets/common.py,NumberFilter,BooleanFilterorChoiceFilter. ACharFilterwhose value is parsed by hand doesn't count. - Serializer fields carry the model's limits (
max_length, min/max value, choices), so a value that passes validation also saves to the database. - One custom DRF
EXCEPTION_HANDLERmaps DjangoValidationErrorto 400 andObjectDoesNotExistto 404, as a backstop. - Studio's
ValuesViewset(contentcuration/contentcuration/viewsets/base.py) is an older copy of Kolibri'skolibri/core/api.py. Fixes there follow Kolibri's shape.
AI usage
I scoped the audit, excluded the internal endpoints, and chose the validation strategy. Claude Code audited every endpoint, reproduced each finding with a temporary test, grouped the findings by root cause, and drafted this issue.
- Lingua principale
- Python
- Stelle
- 212
- Fork
- 321
- Merge medio
- 1g 7h
- PR unite (30g)
- 14
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di learningequality/studio
-
Community library status changes don't update `date_updated`Forse già presa @ArpitaSamanta10 l’ha presa oggi. Apertacommunity-contribution-in-progress DEV: backend good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
learningequality/studio#6414 · 8 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
DEV: backend
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
learningequality/studio#6410 ·
I maintainer di solito rispondono entro 1 giorno
-
DEV: backend
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
learningequality/studio#6409 ·
I maintainer di solito rispondono entro 1 giorno
-
DEV: backend
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
learningequality/studio#6407 ·
I maintainer di solito rispondono entro 1 giorno
-
Stripe webhook accepts events when no webhook secret is configuredForse già presa @adibmbrk l’ha presa oggi. Apertacommunity-contribution-in-progress DEV: backend good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
learningequality/studio#6404 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di learningequality/studio
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
canonical/paas-charm#407 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
FAIRmat-NFDI/pynxtools-spm#136 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
`read_nexus` entry point points to a function that no longer existsForse già presa @RubelMozumder l’ha presa oggi. Apertaannotator bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
FAIRmat-NFDI/pynxtools#876 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: HTTP 499 (Client Closed Request) is classified as a non-retryable format_error, so a mid-flight abort fails the turn over instead of retryingForse già presa @yipinghuang1991 l’ha presa oggi. Apertacomp/agent P2 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
NousResearch/hermes-agent#156837 ·
I maintainer di solito rispondono entro 1 giorno