django-debug-toolbar icon indicating copy to clipboard operation
django-debug-toolbar copied to clipboard

Response status code, JSON body, and response

Open psacawa opened this issue 4 years ago • 4 comments

As far I can tell, after reading the documentation, working with the application for some years, and grepping around the source, DDT doesn't expose any of the response status code, the body of the request if it's JSON, or the rendered response. Is this right?

Surely, at least the response status should be shown every time, while the request/response body can be useful when the request come from an external resource, e.g. a webhook, and is not available to inspect elsewhere.

psacawa avatar Jul 31 '21 23:07 psacawa

I believe the History panel will show the the request body if it's JSON: https://github.com/jazzband/django-debug-toolbar/blob/main/debug_toolbar/panels/history/panel.py#L60 However it does not show any of the response information as you have found out.

And as a note, the toolbar shouldn't be used in production-like environments as it probably doesn't do enough in terms of scrubbing sensitive information and avoiding data leaks.

tim-schilling avatar Aug 04 '21 19:08 tim-schilling

Let me elaborate a bit about the use case.

Some APIs like that of stripe allow to receive webhooks in development. You use a CLI to form a connection to their server and requests are proxied to e.g. localhost:8000/stripe/webhook/. There are often many requests at a time to the same endpoint. This appears in HistoryPanel as a list of POST requests to the same webhook endpoint, with no way to know which one generated 500 reponse without individually inspecting. For that reason, I've opened #1490.

Regarding JSON body, it doesn't work for me, though I didn't inspect why yet. Since JSON in request body is morally similar to form data, I feel it should be manifest in RequestPanel. When I have a moment, I'll do this as well.

psacawa avatar Aug 05 '21 17:08 psacawa

@psacawa were you able to investigate the JSON in the request body not appearing issue?

tim-schilling avatar Aug 25 '21 13:08 tim-schilling

I'm afraid I haven't been able to. I only know it has to do with rest_framework class based views.

psacawa avatar Aug 25 '21 17:08 psacawa

If you can provide us with the ability to recreate the issue, we can re-open this.

tim-schilling avatar Oct 23 '23 00:10 tim-schilling