Opened 6 months ago

Closed 5 months ago

#36267 closed Bug (fixed)

content_type.views.shortcut throws exception handling invalid UUID (View on Site in admin)

Reported by: Andy Shapiro Owned by: Ahmed Nassar
Component: contrib.contenttypes Version: 5.1
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a Django model with a UUID as a primary key. The model has a get_absolute_url implemented, which means in the Django admin, there is a “View on Site” button on the instance detail view.

A valid “View on Site” request looks like this: /admin/r/2/b6a283ce-0529-4ce6-8aa8-3aa5eba4f95b/, where the first parameter 2, is the content type ID, and the 2nd parameter is the UUID for a model instance. An invalid request looks like this: /admin/r/2/bad-uuid-that-will-not-validate/.

If an invalid UUID is passed to this view, the view will raise an unhandled ValidationError on this line .

Because this view is used in the admin application, it requires a staff member to access, so it cannot be thrown by a standard or unathenticated user.

Change History (12)

comment:1 by Andy Shapiro, 6 months ago

Type: UncategorizedBug

comment:2 by Clifford Gama, 6 months ago

Triage Stage: UnreviewedAccepted

Replicated. Thanks for the report!

comment:3 by Ahmed Nassar, 6 months ago

Owner: set to Ahmed Nassar
Status: newassigned

comment:4 by Ahmed Nassar, 6 months ago

Has patch: set

comment:5 by Clifford Gama, 6 months ago

Patch needs improvement: set

comment:6 by Ahmed Nassar, 6 months ago

Patch needs improvement: unset

comment:7 by Sarah Boyce, 5 months ago

Patch needs improvement: set

comment:8 by Ahmed Nassar, 5 months ago

Patch needs improvement: unset

comment:9 by Clifford Gama, 5 months ago

Patch needs improvement: set

comment:10 by Ahmed Nassar, 5 months ago

Patch needs improvement: unset

comment:11 by Clifford Gama, 5 months ago

Triage Stage: AcceptedReady for checkin

comment:12 by Sarah Boyce <42296566+sarahboyce@…>, 5 months ago

Resolution: fixed
Status: assignedclosed

In 00c68f03:

Fixed #36267 -- Fixed contenttypes shortcut() view crash with an invalid object_id for a UUIDField pk.

Note: See TracTickets for help on using tickets.
Back to Top