Django exceptions reach DRF as 500
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 212
- Fork
- 321
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 14
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của learningequality/studio
-
Community library status changes don't update `date_updated`Có thể đã có người làm @LightCreator1007 đã nhận 1 ngày trước. Đang mởDEV: backend good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
learningequality/studio#6414 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DEV: backend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
learningequality/studio#6410 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DEV: backend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
learningequality/studio#6409 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DEV: backend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
learningequality/studio#6407 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DEV: backend good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
learningequality/studio#6404 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của learningequality/studio
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
canonical/paas-charm#407 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
FAIRmat-NFDI/pynxtools-spm#136 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`read_nexus` entry point points to a function that no longer existsCó thể đã có người làm @RubelMozumder đã nhận hôm nay. Đang mởannotator bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
FAIRmat-NFDI/pynxtools#876 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[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 retryingCó thể đã có người làm @yipinghuang1991 đã nhận hôm nay. Đang mởcomp/agent P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NousResearch/hermes-agent#156837 ·
Maintainer thường phản hồi trong vòng 1 ngày