[Django] #36267: content_type.views.shortcut throws exception handling invalid UUID (View on Site in admin)

18 views
Skip to first unread message

Django

unread,
Mar 19, 2025, 11:11:19 PMMar 19
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
--------------------------+------------------------------------------------
Reporter: ashapiro | Type: Uncategorized
Status: new | Component: contrib.contenttypes
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------+------------------------------------------------
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
[https://github.com/django/django/blob/955b7c6ba105b328f387a9d63540dbabd4a05828/django/contrib/contenttypes/views.py#L21
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/36267>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 19, 2025, 11:15:54 PMMar 19
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: (none)
Type: Bug | Status: new
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Andy Shapiro):

* type: Uncategorized => Bug

--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:1>

Django

unread,
Mar 20, 2025, 5:40:18 AMMar 20
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
--------------------------------------+------------------------------------
Reporter: Andy Shapiro | Owner: (none)
Type: Bug | Status: new
Component: contrib.contenttypes | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Clifford Gama):

* stage: Unreviewed => Accepted

Comment:

Replicated. Thanks for the report!
--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:2>

Django

unread,
Mar 20, 2025, 7:58:38 AMMar 20
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmed Nassar):

* owner: (none) => Ahmed Nassar
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:3>

Django

unread,
Mar 21, 2025, 11:14:52 AMMar 21
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmed Nassar):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:4>

Django

unread,
Mar 22, 2025, 8:07:54 AMMar 22
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:5>

Django

unread,
Mar 22, 2025, 7:49:30 PMMar 22
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmed Nassar):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:6>

Django

unread,
Mar 24, 2025, 4:24:44 AMMar 24
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:7>

Django

unread,
Mar 31, 2025, 3:01:09 PMMar 31
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmed Nassar):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:8>

Django

unread,
Mar 31, 2025, 4:41:59 PMMar 31
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:9>

Django

unread,
Mar 31, 2025, 10:26:24 PMMar 31
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmed Nassar):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:10>

Django

unread,
Apr 1, 2025, 2:35:07 AMApr 1
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:11>

Django

unread,
Apr 2, 2025, 3:33:25 AMApr 2
to django-...@googlegroups.com
#36267: content_type.views.shortcut throws exception handling invalid UUID (View on
Site in admin)
-------------------------------------+-------------------------------------
Reporter: Andy Shapiro | Owner: Ahmed
| Nassar
Type: Bug | Status: closed
Component: | Version: 5.1
contrib.contenttypes |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"00c68f03b5dc6c14618026347ee0da4d466c88e3" 00c68f03]:
{{{#!CommitTicketReference repository=""
revision="00c68f03b5dc6c14618026347ee0da4d466c88e3"
Fixed #36267 -- Fixed contenttypes shortcut() view crash with an invalid
object_id for a UUIDField pk.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36267#comment:12>
Reply all
Reply to author
Forward
0 new messages