Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32148 closed Bug (wontfix)

Exception reporter returns text/html response when X-Requested-With is set.

Reported by: Jonah Bishop Owned by:
Component: Error reporting Version: 3.1
Severity: Normal Keywords:
Cc: Claude Paroz Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Prior to 3.1, exceptions encountered during an AJAX-style request were returned as text/plain content (see ticket #10841). Ticket #30752 introduced a new ExceptionReporter subclass feature in 3.1, which appears to have changed the out-of-the-box behavior. Now all exceptions return text/html content, regardless of whether they occur in an AJAX-style request or not. This makes parsing errors that occur from an AJAX-style request a lot harder. I was unable to find any details on this nuance in the 3.1 documentation.

Change History (2)

comment:1 by Mariusz Felisiak, 4 years ago

Cc: Claude Paroz added
Resolution: wontfix
Status: newclosed
Summary: Exceptions always return text/html response, even in AJAX caseExceptions always return text/html response, even in AJAX case.

It's not related with #30752. This is caused by #30997 (see 7fa0fa45c5786619409036c5adce52ff6189b0ac). We deprecated is_ajax() which uses the non-standard X-Requested-With header and removed it's usage from Django. The logic behind the decision to return a different exception content is now based on the Accept HTTP header, you should set it to application/json.

comment:2 by Mariusz Felisiak, 4 years ago

Summary: Exceptions always return text/html response, even in AJAX case.Exception reporter returns text/html response when X-Requested-With is set.
Note: See TracTickets for help on using tickets.
Back to Top