Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling when DJDT views don't respond with JSON #1847

Closed
TreyWW opened this issue Oct 23, 2023 · 19 comments · Fixed by #1877
Closed

Improve handling when DJDT views don't respond with JSON #1847

TreyWW opened this issue Oct 23, 2023 · 19 comments · Fixed by #1877

Comments

@TreyWW
Copy link

TreyWW commented Oct 23, 2023

Sidebar loads fine until you press any of the buttons, for example "Cache".

As soon as i press it i get
image

VM14865:2 Uncaught (in promise) SyntaxError: Unexpected token '<', "
<html>

<h"... is not valid JSON

I load django toolbar at the start so

urlpatterns = [

]
if settings.DEBUG:
    import debug_toolbar

    urlpatterns += [
        url("__debug__/", include(debug_toolbar.urls)),
    ]

urlpatterns += [] # my normal urls

Also does it after my normal urls. Does it in all of my projects now, not sure why but it's really annoying. One of my other test pages calls a request every 7 seconds, and each time it fetches data i get that error on my screen. So annoying.

I'm happy to provide more details

Thanks :)


Edit from Tim:

This issue is because the toolbar views have some authorization logic wrapping them causing the responses to be HTML rather than JSON. Our JS frontend should identify when the responses don't match expectations and notify the user of such to make it easier to diagnose.

@TreyWW
Copy link
Author

TreyWW commented Oct 23, 2023

Also error comes from here

image

@tim-schilling
Copy link
Member

Can you share what's going on in the network panel of the browser developer tools? Something is returning an html response when it's not expected.

@TreyWW
Copy link
Author

TreyWW commented Oct 23, 2023

Sure thing

image
image

aha, http://127.0.0.1:8000/login/?next=/__debug__/history_sidebar/%3Fstore_id%3D221f0a9e2ea44d7ba227eddf737e62d7

By that i assume it's trying to login to view things. I need to find the url name to an allowed list to avoid it being blocked
I'll let you know if i cant find it

@tim-schilling

This comment was marked as resolved.

@tim-schilling tim-schilling changed the title Unexpected token '<', " Improve handling when DJDT views don't respond with JSON Oct 23, 2023
@TreyWW

This comment was marked as resolved.

@tim-schilling

This comment was marked as resolved.

@TreyWW

This comment was marked as resolved.

@tim-schilling

This comment was marked as resolved.

@TreyWW

This comment was marked as resolved.

@tim-schilling

This comment was marked as resolved.

@TreyWW

This comment was marked as resolved.

@TreyWW TreyWW closed this as completed Oct 23, 2023
@tim-schilling tim-schilling reopened this Oct 23, 2023
@tim-schilling
Copy link
Member

Re-opening because I'm re-purposing the issue

@TreyWW

This comment was marked as resolved.

@TreyWW

This comment was marked as resolved.

@matthiask

This comment was marked as resolved.

@folt

This comment was marked as off-topic.

@tim-schilling

This comment was marked as off-topic.

@folt

This comment was marked as off-topic.

@tim-schilling

This comment was marked as off-topic.

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