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

Fixed issue with toolbar expecting urls to start with __debug__. #1453

Merged
merged 2 commits into from Mar 6, 2021

Conversation

tim-schilling
Copy link
Contributor

@tim-schilling tim-schilling commented Feb 12, 2021

When the history panel was added and we expanded the number of
urls we were instrumenting, there was a check added to exclude
the requests to the toolbar's views. This was done by checking
the path of the request to see if it started with __debug__.
However, the documentation states that is not a requirement.
This change checks the urls to see if the namespace of the
resolved url matches the toolbar's namespace.

This still isn't perfect as another url path could contain the
last namespace of djdt, but this is much less likely than a user
defining the toolbar's urls at a different path than /__debug__/

When the history panel was added and we expanded the number of
urls we were instrumenting, there was a check added to exclude
the requests to the toolbar's views. This was done by checking
the path of the request to see if it started with __debug__.
However, the documentation states that is not a requirement.
This change checks the urls to see if the namespace of the
resolved url matches the toolbar's namespace.

This still isn't perfect as another url path could contain the
last namespace of djdt, but this is much less likely than a user
defining the toolbar's urls at a different path than /__debug__/
@codecov
Copy link

codecov bot commented Feb 12, 2021

Codecov Report

Merging #1453 (135e7ca) into main (3dc5437) will increase coverage by 0.25%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1453      +/-   ##
==========================================
+ Coverage   86.80%   87.05%   +0.25%     
==========================================
  Files          29       29              
  Lines        1591     1599       +8     
  Branches      224      224              
==========================================
+ Hits         1381     1392      +11     
+ Misses        153      150       -3     
  Partials       57       57              
Impacted Files Coverage Δ
debug_toolbar/middleware.py 95.00% <100.00%> (ø)
debug_toolbar/toolbar.py 89.77% <100.00%> (+1.02%) ⬆️
debug_toolbar/panels/profiling.py 89.28% <0.00%> (+2.67%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3dc5437...135e7ca. Read the comment docs.

@matthiask matthiask merged commit b17d7bc into jazzband:main Mar 6, 2021
@matthiask
Copy link
Member

Thanks, this makes a lot of sense. I thought at first it may be a better idea to just reverse the debug toolbar's own URL and to a prefix match, but checking the namespace is probably better. The .resolver_match is even documented so that's good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants