[Django] #26059: BrokenLinkEmailsMiddleware flagging invalid *referer* URL

14 views
Skip to first unread message

Django

unread,
Jan 8, 2016, 8:49:22 AM1/8/16
to django-...@googlegroups.com
#26059: BrokenLinkEmailsMiddleware flagging invalid *referer* URL
-------------------------+-------------------------------------------------
Reporter: | Owner: nobody
marktranchant |
Type: Bug | Status: new
Component: Core | Version: 1.9
(URLs) |
Severity: Normal | Keywords: BrokenLinkEmailsMiddleware, referer
Triage Stage: | Has patch: 0
Unreviewed |
Easy pickings: 0 | UI/UX: 0
-------------------------+-------------------------------------------------
My project has a URL for users in the format {{{/staff/$USERNAME}}}. The
view contains a form allows the user to update their details and redirects
to {{{/staff}}} on submission.

Recently (since either 1.9 or 1.9.1), I've been getting Broken Link email
alerts without a corresponding 404 in the {{{nginx}}} server logs. It
turns out these are being generated when the user updates their username,
so when the redirect occurs, {{{/staff/$OLD_USERNAME}}} (the referer URL)
is no longer valid.

My project has not changed in the way it processes these requests: this is
a new feature/bug/regression in Django, as far as I can tell.

{{{
Referrer: https://myproject/staff/wonko_the_sane/
Requested URL: /staff
User agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101
Firefox/43.0
IP address: 127.0.0.1
}}}

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

Django

unread,
Jan 8, 2016, 9:25:43 AM1/8/16
to django-...@googlegroups.com
#26059: BrokenLinkEmailsMiddleware flagging invalid *referer* URL
-------------------------------------+-------------------------------------
Reporter: marktranchant | Owner: nobody
Type: Bug | Status: new
Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage:
BrokenLinkEmailsMiddleware, | Unreviewed
referer |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Could you
[https://github.com/django/django/blob/59ef6559a31c175c1f52668ef0ffe9b8d87aa5a5/tests/middleware/tests.py#L333
provide a test] to reproduce the issue?

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

Django

unread,
Jan 8, 2016, 9:42:46 AM1/8/16
to django-...@googlegroups.com
#26059: BrokenLinkEmailsMiddleware flagging invalid *referer* URL
-------------------------------------+-------------------------------------
Reporter: marktranchant | Owner: nobody
Type: Bug | Status: new

Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage:
BrokenLinkEmailsMiddleware, | Unreviewed
referer |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by marktranchant):

I'll have a go, but looking at the relatively simple middleware code, I'm
not sure that's where the problem lies.

{{{
class BrokenLinkEmailsMiddleware(object):
def process_response(self, request, response):
if response.status_code == 404 and not settings.DEBUG:
# (send the email)
}}}

It looks from that as though the '''referer''' URL is being queried at
some point, and the middleware is doing what it should.

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

Django

unread,
Jan 8, 2016, 9:44:56 AM1/8/16
to django-...@googlegroups.com
#26059: BrokenLinkEmailsMiddleware flagging invalid *referer* URL
-------------------------------------+-------------------------------------
Reporter: marktranchant | Owner: nobody
Type: Bug | Status: new

Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage:
BrokenLinkEmailsMiddleware, | Unreviewed
referer |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

Any chance this is related to `APPEND_SLASH` and #25971?

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

Django

unread,
Jan 8, 2016, 3:21:59 PM1/8/16
to django-...@googlegroups.com
#26059: BrokenLinkEmailsMiddleware flagging invalid *referer* URL
-------------------------------------+-------------------------------------
Reporter: marktranchant | Owner: nobody
Type: Bug | Status: closed

Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
BrokenLinkEmailsMiddleware, | Unreviewed
referer |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by marktranchant):

* status: new => closed
* resolution: => invalid


Comment:

Done some testing and yes, it is #25971, not the newly-invalid referer.
Marked ticket as invalid.

Many thanks for the pointer. I had seen that but not realized the
relevance.

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

Django

unread,
Apr 21, 2025, 1:43:07 PM4/21/25
to django-...@googlegroups.com
#26059: BrokenLinkEmailsMiddleware flagging invalid *referer* URL
-------------------------------------+-------------------------------------
Reporter: Mark Tranchant | Owner: nobody
Type: Bug | Status: closed
Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
BrokenLinkEmailsMiddleware, | Unreviewed
referer |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* resolution: invalid => duplicate

--
Ticket URL: <https://code.djangoproject.com/ticket/26059#comment:5>
Reply all
Reply to author
Forward
0 new messages