Re: [Django] #37025: RemoteUserTest masks behavior difference between WSGI & ASGI for .headers attribute (was: RemoteUserMiddleware.header does not correspond to request.META in the async path)

2 views
Skip to first unread message

Django

unread,
May 1, 2026, 12:45:22 PMMay 1
to django-...@googlegroups.com
#37025: RemoteUserTest masks behavior difference between WSGI & ASGI for .headers
attribute
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: Bug | Status: assigned
Component: contrib.auth | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
RemoteUserMiddleware |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* summary:
RemoteUserMiddleware.header does not correspond to request.META in the
async path
=>
RemoteUserTest masks behavior difference between WSGI & ASGI for
.headers attribute

Comment:

Thanks Mykhailo and Sarah for the illuminating reviews. After checking the
history, this is a regression in Django 5.2
(50f89ae850f6b4e35819fe725a08c7e579bfd099) that was not caught in time for
a backport. RemoteUserMiddleware's default `REMOTE_USER` value didn't work
before that commit, but in fixing the default case, we broke (or "changed
the semantic") of the custom header case.

It was reported in time (#36300), but only as a "hunch", so it was closed
as `needsinfo`. I'll reopen and aim to fix in Django 6.1 without a
deprecation or a backport, but with a release note.

I'll open a separate ticket for Mykhailo's finding about the sync path
looking up the wrong header under ASGI. The prior PR of mine already had a
fix for that incidental finding, but I'll start over. (To fix that, we'll
end up needing a helper along the lines of #35971, which was opened for a
totally unrelated reason.)

[https://github.com/django/django/pull/21207 PR for test updates]

I'd like to reframe this ticket to just fix the existing tests to show the
problem more clearly. Then we can fix it when closing #36300.
--
Ticket URL: <https://code.djangoproject.com/ticket/37025#comment:19>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages