[Django] #34691: Add a system check for unmatched URL paths' < / >

3 views
Skip to first unread message

Django

unread,
Jul 3, 2023, 9:45:44 AM7/3/23
to django-...@googlegroups.com
#34691: Add a system check for unmatched URL paths' < / >
------------------------------------------------+------------------------
Reporter: Adam Johnson | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: dev
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 |
------------------------------------------------+------------------------
Currently, unmatched angle brackets are silently ignored:

{{{
path('<int:question_id/vote/', views.vote, name='vote'),
}}}

This leads to a frustrating debugging experience, where a 404 or
`NoReverseMatch` could occur and only the eagle-eyed could spot why.
Similar to the `^`/`$` system check added in #28663, I propose a new check
in `RoutePattern.check()` for unmatched `<` or `>`. It's rather unlikely
those characters are legitimately used in URLs.

(Inspired by [https://forum.djangoproject.com/t/noreversematch-at-end-of-
tutorial-4/6513/9 a new user making this mistake] and asking for help on
the forum.)

--
Ticket URL: <https://code.djangoproject.com/ticket/34691>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 3, 2023, 6:07:32 PM7/3/23
to django-...@googlegroups.com
#34691: Add a system check for unmatched URL paths' < / >
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amir
Type: | Karimi
Cleanup/optimization | Status: assigned

Component: Core (URLs) | Version: dev
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 Amir Karimi):

* owner: nobody => Amir Karimi
* status: new => assigned


Comment:

Seems essential. I can work on it by splitting the routes based on '/' and
checking if each part having started with '<' must have ended with '>'.

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

Django

unread,
Jul 3, 2023, 11:16:37 PM7/3/23
to django-...@googlegroups.com
#34691: Add a system check for unmatched URL paths' < / >
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amir
Type: | Karimi
Cleanup/optimization | Status: assigned
Component: Core (System | Version: dev
checks) |
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 Mariusz Felisiak):

* component: Core (URLs) => Core (System checks)
* stage: Unreviewed => Accepted


Comment:

Sounds reasonable, this should raise a system check warning, not an error.

--
Ticket URL: <https://code.djangoproject.com/ticket/34691#comment:2>

Django

unread,
Jul 4, 2023, 10:06:29 AM7/4/23
to django-...@googlegroups.com
#34691: Add a system check for unmatched URL paths' < / >
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amir
Type: | Karimi
Cleanup/optimization | Status: assigned
Component: Core (System | Version: dev
checks) |
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 Amir Karimi):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/17045]

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

Django

unread,
Jul 5, 2023, 1:54:19 AM7/5/23
to django-...@googlegroups.com
#34691: Add a system check for unmatched URL paths' < / >
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amir
Type: | Karimi
Cleanup/optimization | Status: assigned
Component: Core (System | Version: dev
checks) |
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 Mariusz Felisiak):

* needs_better_patch: 0 => 1


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

Django

unread,
Jul 11, 2023, 5:46:55 AM7/11/23
to django-...@googlegroups.com
#34691: Add a system check for unmatched URL paths' < / >
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amir
Type: | Karimi
Cleanup/optimization | Status: assigned
Component: Core (System | Version: dev
checks) |
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 Mariusz Felisiak):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


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

Django

unread,
Jul 11, 2023, 8:05:48 AM7/11/23
to django-...@googlegroups.com
#34691: Add a system check for unmatched URL paths' < / >
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amir
Type: | Karimi
Cleanup/optimization | Status: closed

Component: Core (System | Version: dev
checks) |
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 Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"d1855c4847215f3afe3708736be13388bb6437eb" d1855c48]:
{{{
#!CommitTicketReference repository=""
revision="d1855c4847215f3afe3708736be13388bb6437eb"
Fixed #34691 -- Added system check for unmatched angle brackets in path().
}}}

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

Django

unread,
Jul 11, 2023, 4:45:42 PM7/11/23
to django-...@googlegroups.com
#34691: Add a system check for unmatched URL paths' < / >
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amir
Type: | Karimi
Cleanup/optimization | Status: closed
Component: Core (System | Version: dev
checks) |
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
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"e5e9699e0fe1e7affe3c68082ed1e205726a4c79" e5e9699]:
{{{
#!CommitTicketReference repository=""
revision="e5e9699e0fe1e7affe3c68082ed1e205726a4c79"
Refs #34691 -- Optimized system check for unmatched angle brackets in
path().

Follow up to d1855c4847215f3afe3708736be13388bb6437eb.
}}}

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

Reply all
Reply to author
Forward
0 new messages