Skip to content

Fix 'No POST data' in ExceptionReporter and AdminEmailHandler for non-form requests (#7953) - #10088

Open
SirFassler wants to merge 2 commits into
encode:mainfrom
SirFassler:fix-request-post-json-error-report
Open

SirFassler wants to merge 2 commits into
encode:mainfrom
SirFassler:fix-request-post-json-error-report

Conversation

@SirFassler

Copy link
Copy Markdown

Description

Fixes #7953.

When an unhandled exception occurs in a view processing a request with a JSON or non-form payload, Django's ExceptionReporter and AdminEmailHandler rendered POST: No POST data because:

  1. Request.POST returned an empty QueryDict for non-form media types.
  2. Sychronization to the underlying HttpRequest._post was restricted to form media types in Fix request formdata handling #5800.
  3. Access to request.FILES in ExceptionReporter.get_traceback_data() subsequently triggered Django's _load_post_and_files(), setting _post to an empty QueryDict.

Changes

  • In rest_framework/request.py: allow Request.POST to return parsed dictionary data when available.
  • In rest_framework/views.py: in raise_uncaught_exception(), populate _post and _files on the underlying HttpRequest before re-raising so Django's exception reporting machinery has access to the payload.
  • Added regression test TestExceptionReporting.test_uncaught_exception_json_post_data_in_exception_reporter verifying that filtered_POST_items, HTML tracebacks, and plain text reports include the parameters rather than No POST data.

All 1,579 test suite cases pass.

…ors (encode#7953)

When an uncaught exception occurs during a request with a JSON or non-form
payload, Django's ExceptionReporter (and AdminEmailHandler) rendered
'POST: No POST data' because the underlying HttpRequest._post remained
empty.

- In APIView.raise_uncaught_exception, copy parsed request data and files to
  the underlying HttpRequest._post and HttpRequest._files before re-raising.
- Add regression test asserting ExceptionReporter filtered_POST_items and
  rendered traceback output.
@SirFassler
SirFassler force-pushed the fix-request-post-json-error-report branch from b1e3af4 to d733a47 Compare October 27, 2026 03:03
@auvipy
auvipy self-requested a review October 28, 2026 07:03
@auvipy auvipy added this to the 3.19 milestone Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

"No POST data" in error report

2 participants