Opened 6 months ago
Last modified 6 months ago
#35673 assigned Bug
ExceptionReporter.get_traceback_data() does not handle when request.GET data exceeds DATA_UPLOAD_MAX_NUMBER_FIELDS
Description ¶
When the number of query parameters in URL exceeds settings.DATA_UPLOAD_MAX_NUMBER_FIELDS, Django takes more than a second to generate the error page and eventually returns HTTP 500 with a blank page. The "manage.py runserver" output shows a long chain of exceptions, delimited with "The above exception was the direct cause of the following exception:" line.
To reproduce: start a new Django project, and place the following in urls.py:
from django.http import HttpResponse from django.urls import path def index(request): request.GET.getlist("a") url = "/?" + "&".join([f"a={i}" for i in range(0, 1001)]) return HttpResponse(f"""<a href="{url}">Click me</a>""", content_type="text/html") urlpatterns = [ path("", index), ]
The problem is only triggered if
- DEBUG=True (otherwise, Django generates a HTTP 400 response with no delay)
- If the view accesses request.GET
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (5)
comment:1 by , 6 months ago
Summary: | When URL has 1000+ query parameters, and DEBUG=True, Django does not generate the error page correctly → ExceptionReporter.get_traceback_data() does not handle when request.GET data exceeds DATA_UPLOAD_MAX_NUMBER_FIELDS |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 6 months ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:5 by , 6 months ago
We are encountering a very specific and complex error in the lower layers of the framework. Currently, we use request.GET
to retrieve GET parameters. However, if request.GET
encounters an error for any reason, how can the higher layers of the framework access these values and display the necessary information on the error page?
which this issue's scenario has exactly the very same problem.
What is your opinion on this?
Thank you!
Here's a rough test
TabularUnified tests/view_tests/tests/test_debug.py
TabularUnified tests/view_tests/views.py