Validate UUIDField values when a queryset is filtered, not when it runs
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 54/100
Hướng nghiên cứu
Read morango/models/fields/uuids.py and compare UUIDField's preparation path with Django's UUIDField.get_prep_value. Add or update tests for filter(), __in lookups, and accepted UUID formats; the issue does not name a test file. Done means malformed values raise ValidationError with code invalid when the queryset is built, while valid values still filter and save as 32-character hex.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
morango's UUIDField checks values only in get_db_prep_value, which runs when a queryset executes. Django's fields check values in get_prep_value, which runs when .filter() is called, so callers that wrap .filter() in try (Django forms, django-filter, DRF's get_object_or_404) never see morango's error. Kolibri's API returns a 500 for malformed ids in many places because of this.
Complexity: Low
Target branch: release-v0.9.x
Context
In morango/models/fields/uuids.py:
Model.objects.filter(id="abc")succeeds. Evaluating it raisesValueError: badly formed hexadecimal UUID string.Model.objects.filter(id=5)orfilter(id={"a": 1})raisesKeyError: 'invalid'on evaluation, becauseget_db_prep_valuereadsself.error_messages["invalid"], whichCharFielddoesn't define.
Django's own UUIDField.get_prep_value calls to_python, which raises django.core.exceptions.ValidationError with code invalid.
The Change
- morango's
UUIDFieldshould reject a malformed value when the lookup is built, raisingdjango.core.exceptions.ValidationErrorwith codeinvalid, as Django'sUUIDFielddoes. - Values the field accepts today (32-char hex, dashed UUID strings,
uuid.UUIDinstances) keep working and keep being stored as 32-char hex.
Acceptance Criteria
-
filter(id="abc")raisesValidationErrorwith codeinvalidwhen.filter()is called. -
filter(id=5),filter(id={"a": 1})andfilter(id=["a"])raise the sameValidationError, notKeyErrororTypeError. -
filter(id__in=["abc"])raises the sameValidationError. - Hex, dashed and
uuid.UUIDvalues filter and save as before. - Released in a 0.9.x release.
AI usage
I had Claude Code sweep Kolibri's API code for unvalidated request input and trace the malformed-id 500s to this field. I chose the fix. Claude Code drafted the issue. Kolibri tracking issue: learningequality/kolibri#15838.
- Ngôn ngữ chính
- Python
- Star
- 15
- Fork
- 27
- Merge trung bình
- 6 ngày 44 phút
- Pull request đã merge (30 ngày)
- 13
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- 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/morango
-
Document disk export and deprecations in the changelogCó thể làm lại được @ArpitaSamanta10 đã nhận 14 ngày trước và không có pull request nào đang mở. Đang mởDEV: dev-ops DEV: distributions DOCS: developer
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
learningequality/morango#387 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DEV: backend DEV: dev-ops TAG: unit tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
learningequality/morango#385 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 1/100
learningequality/morango#424 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DEV: backend P2 - normal
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
learningequality/morango#416 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
dependencies DEV: dev-ops TAG: dependencies
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
learningequality/morango#399 · 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/morango
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
hermes hooks doctor smoke test never checks the hook exit code — a crashing hook (exit=1) renders ✓ "ran clean" and "All shell hooks look healthy"Có thể đã có người làm @cestercian đã nhận hôm nay. Đang mởcomp/cli P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NousResearch/hermes-agent#162259 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
AOSSIE-Org/PictoPy#1802 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
community-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NVIDIA-NeMo/Run#727 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bot-triaged module: higher order operators module: pickle module: pt2-dispatcher oncall: pt2 triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
pytorch/pytorch#207247 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày