Opened 5 years ago

Closed 5 years ago

#25037 closed New feature (fixed)

Add request.user to the debug view

Reported by: Grigoriy Kramarenko Owned by: John Moses
Component: Error reporting Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Displays the username in the mail for admins (used in views.debug.ExceptionReporterFilter) that caused the error:

Request repr():
<HttpRequest
path:/somepath/,
USER:None,
GET:{'get-key': 'get-value'},
POST:{'post-key': 'post-value'},
COOKIES:{'post-key': 'post-value'},
META:{'post-key': 'post-value'}>

Attachments (1)

25037.diff (4.2 KB) - added by Grigoriy Kramarenko 5 years ago.

Download all attachments as: .zip

Change History (17)

Changed 5 years ago by Grigoriy Kramarenko

Attachment: 25037.diff added

comment:1 Changed 5 years ago by Grigoriy Kramarenko

Has patch: set

comment:2 Changed 5 years ago by Claude Paroz

Component: UncategorizedHTTP handling
Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

I think this is a nice addition. Would it be possible to transform the patch in a pull request?
We'll also need more tests (with anonymous user, authenticated user, custom user, etc.).

comment:3 Changed 5 years ago by Tim Graham

Although it's a common pattern to set request.user, I had some reservations about coupling HttpRequest and contrib.auth when I first read this.

Sentry seems to have some way to associate exceptions with users. Maybe it would be worth looking at how they accomplish that?

comment:4 in reply to:  3 Changed 5 years ago by Grigoriy Kramarenko

Replying to timgraham:

Although it's a common pattern to set request.user, I had some reservations about coupling HttpRequest and contrib.auth when I first read this.

Sentry seems to have some way to associate exceptions with users. Maybe it would be worth looking at how they accomplish that?

This decision does not depend on contrib.auth and request.user. But when there they - it is of great help to solve the problems of administrators.

Maybe need test with 2 options: with request.user and without it.

Last edited 5 years ago by Grigoriy Kramarenko (previous) (diff)

comment:5 Changed 5 years ago by Vlastimil Zíma

Note, that build_request_repr was removed in #25099.

comment:6 Changed 5 years ago by Tim Graham

Component: HTTP handlingError reporting
Easy pickings: set
Summary: Addition to functions http.requests.build_request_reprAdd request.user to the debug view

It seems the new alternative would be to add it to views.debug.TECHNICAL_500_TEMPLATE and TECHNICAL_500_TEXT_TEMPLATE under "Request information".

comment:7 Changed 5 years ago by Julian Gindi

Owner: changed from nobody to Julian Gindi
Status: newassigned

comment:8 Changed 5 years ago by Julian Gindi

Based on the latest comment, I'll move ahead with the mentioned implementation as opposed to continuing the work from the first patch. Does that sound right?

comment:9 Changed 5 years ago by Tim Graham

Yes, the initial patch will no longer apply.

comment:10 Changed 5 years ago by John Moses

Where should the associated test with this go?

comment:11 Changed 5 years ago by Tim Graham

There are tests for the debug view in tests/view_tests/tests/test_debug.py.

comment:12 Changed 5 years ago by John Moses

Owner: changed from Julian Gindi to John Moses

comment:13 Changed 5 years ago by John Moses

comment:14 Changed 5 years ago by Tim Graham

Needs tests: unset

comment:15 Changed 5 years ago by John Moses

Patch needs improvement: unset

comment:16 Changed 5 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 2b6344e:

Fixed #25037 -- Added request.user to the debug view.

Note: See TracTickets for help on using tickets.
Back to Top