Re: [Django] #35169: updated asgi handler for disconnects does not process ROOT_PATH

13 views
Skip to first unread message

Django

unread,
Feb 6, 2024, 7:19:54 AMFeb 6
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: Carlton Gibson (added)
* status: new => closed
* resolution: => needsinfo

Comment:

Thanks for the report, however, I'm puzzled, `process_request()` has never
accepted or passed a `scope` (even before
1d1ddffc27cd55c011298cd09bfa4de3fa73cf7a), so how this can be a
regression? Also, `scope` is an element of `request` so why you need to
pass it separately and call `set_script_prefix()`. This should be already
handled by
[https://github.com/django/django/blob/9cefdfc43f0bae696b56fa5a0bf22346f85affff/django/core/handlers/asgi.py#L172-L190
ASGIHandler].
--
Ticket URL: <https://code.djangoproject.com/ticket/35169#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 6, 2024, 7:31:33 AMFeb 6
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Carlton Gibson):

Root path handling was adjusted in Uvicorn just recently.
https://github.com/encode/uvicorn/pull/2213
--
Ticket URL: <https://code.djangoproject.com/ticket/35169#comment:4>

Django

unread,
Feb 6, 2024, 7:32:38 AMFeb 6
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Michael Smith):

all i can say is that when we upgraded to django 5 from 4.2.9, all the
template url references outside of static files lost their root_path
prefixes. By making these changes I was able to get the root_path passed
back to the templates. If you have another way to resolve this, please but
I have not been able to get the ROOT_PATH from uvicorn asgi server passed
back to our application without this. I used git bisect to identify the
specific commit that caused this. And by adding the scope, it restored the
django 4 behavior.
--
Ticket URL: <https://code.djangoproject.com/ticket/35169#comment:5>

Django

unread,
Feb 6, 2024, 7:39:05 AMFeb 6
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak):

> all i can say is that when we upgraded to django 5 from 4.2.9

Are you sure that it's not related with the `uvicorn` update?

> I used git bisect to identify the specific commit that caused this.

Can you add a regression test? You had to have one to actually bisect.
--
Ticket URL: <https://code.djangoproject.com/ticket/35169#comment:6>

Django

unread,
Feb 6, 2024, 7:52:51 AMFeb 6
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Michael Smith):

I will add a regression test
--
Ticket URL: <https://code.djangoproject.com/ticket/35169#comment:7>

Django

unread,
Feb 6, 2024, 7:56:32 AMFeb 6
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Michael Smith):

It may be that process_request does not need scope but just
run_get_response. I will determine what exactly is needed with the
regression test
--
Ticket URL: <https://code.djangoproject.com/ticket/35169#comment:8>

Django

unread,
Feb 6, 2024, 8:07:43 AMFeb 6
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Carlton Gibson):

@Michael. `set_script_prefix` targets a `Local`, so if we change thread
maybe the value gets lost, but I'm not seeing yet how that can be
happening (in anything related to
1d1ddffc27cd55c011298cd09bfa4de3fa73cf7a) — Happy to have a look once
you've got a reproduce. Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/35169#comment:9>

Django

unread,
Feb 14, 2024, 2:37:16 AMFeb 14
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sören Weber):

* cc: Sören Weber (added)

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

Django

unread,
Mar 19, 2024, 10:32:57 PMMar 19
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by ajslater):

I've run into the same problem, except with hypercorn.
script prefixes are no longer prefixed from hypercorn root_path with
Django 5.0.0+ They are prefixed with Django 4.2.11 and the same hypercorn
version.

My workaround right now is to manually call `set_script_prefix()` in my
`urls.py`:
{{{
from django.urls import set_script_prefix
from myapp.settings import MANUALLY_PARSED_HYPERCORN_SETTINGS

set_script_prefix(MANUALLY_PARSED_HYPERCORN_SETTINGS.root_path)

urlpatterns = [ ... ]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35169#comment:11>

Django

unread,
Apr 5, 2024, 3:13:52 AMApr 5
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Carlton Gibson):

I've created a [https://github.com/django/django/pull/18048 PR adding a
test for this here]. The test passes (on both main and stable/4.2.x
branches).

Comment from there:

> Possible change may be in 041b0a3 @sarahboyce: maybe folks have
FORCE_SCRIPT_NAME set to a non-None value. That's the sort of thing once
might have done when experimenting with mounting under a root_path.
> If it's not that, then I'm out of ideas without a reproduce.
--
Ticket URL: <https://code.djangoproject.com/ticket/35169#comment:12>

Django

unread,
Apr 5, 2024, 5:30:44 AMApr 5
to django-...@googlegroups.com
#35169: updated asgi handler for disconnects does not process ROOT_PATH
-------------------------------------+-------------------------------------
Reporter: Michael Smith | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: asgi, handler, | Triage Stage:
root_path | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"4d2ef9bb826db76acb5ed7609a9162de9b651921" 4d2ef9b]:
{{{#!CommitTicketReference repository=""
revision="4d2ef9bb826db76acb5ed7609a9162de9b651921"
Refs #35169 -- Added test for ASGIRequest root_path handling.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35169#comment:13>
Reply all
Reply to author
Forward
0 new messages