Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#26059 closed Bug (invalid)

BrokenLinkEmailsMiddleware flagging invalid *referer* URL

Reported by: Mark Tranchant Owned by: nobody
Component: Core (URLs) Version: 1.9
Severity: Normal Keywords: BrokenLinkEmailsMiddleware, referer
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (4)

comment:1 by Tim Graham, 9 years ago

Could you provide a test to reproduce the issue?

comment:2 by Mark Tranchant, 9 years ago

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.

comment:3 by Tim Graham, 9 years ago

Any chance this is related to APPEND_SLASH and #25971?

comment:4 by Mark Tranchant, 9 years ago

Resolution: invalid
Status: newclosed

Done some testing and yes, it is #25971, not the newly-invalid referer. With the redirect to /staff/ (with slash) the error disappears. Marked ticket as invalid.

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

Last edited 9 years ago by Mark Tranchant (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top