Skip to content

Reorder URLs so that Django debug toolbar can work#16352

Open
AlanCoding wants to merge 1 commit intoansible:develfrom
AlanCoding:fix_ddt
Open

Reorder URLs so that Django debug toolbar can work#16352
AlanCoding wants to merge 1 commit intoansible:develfrom
AlanCoding:fix_ddt

Conversation

@AlanCoding
Copy link
Member

@AlanCoding AlanCoding commented Mar 12, 2026

SUMMARY

Go discover your internal IP and then put in:

diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py
index 1f6b7ae2b2..c6d7c64117 100644
--- a/awx/settings/defaults.py
+++ b/awx/settings/defaults.py
@@ -149,7 +149,8 @@ else:
 
 # Hosts/domain names that are valid for this site; required if DEBUG is False
 # See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
-ALLOWED_HOSTS = []
+ALLOWED_HOSTS = ['*']
+
 
 # HTTP headers and meta keys to search to determine remote host name or IP. Add
 # additional items to this list, such as "HTTP_X_FORWARDED_FOR", if behind a
@@ -356,7 +357,7 @@ INSTALLED_APPS = [
 ]
 
 
-INTERNAL_IPS = ('127.0.0.1',)
+INTERNAL_IPS = ('172.18.0.1')
 
 MAX_PAGE_SIZE = 200
 REST_FRAMEWORK = {

and then try and use the django debug toolbar, was giving this when looking for the SQL:

Data for this panel isn't available anymore. Please reload the page and retry

This fixes it.

The issue is that the UI urls were getting included unconditionally before the DDT urls, and that means that it would match the /debug/ URL that's necessary for the thing to work.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API

Note

Low Risk
Low risk ordering change to URL patterns; main risk is unintended routing precedence changes for non-API paths in development mode.

Overview
Reorders URL registration so the UI catch-all route (re_path(r'^(?!api/).*'...)) is appended after the optional Django Debug Toolbar routes.

This prevents /__debug__/ requests from being swallowed by the UI URL include when settings.DYNACONF.is_development_mode is enabled.

Written by Cursor Bugbot for commit f5d8433. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Refactor
    • Reorganized URL routing configuration for improved code structure. No changes to application functionality or user experience.

@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

The UI URL resolver inclusion was moved from the initial urlpatterns list to a separate urlpatterns += block appended after the development-mode debug toolbar configuration. URL routing behavior and negative lookahead patterns for excluding API paths remain unchanged.

Changes

Cohort / File(s) Summary
URL Configuration
awx/urls.py
Reordered UI URL resolver registration to append after debug toolbar handling instead of inline with initial urlpatterns declaration.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the primary change: reordering URLs to ensure Django debug toolbar functionality. It is concise, specific, and directly related to the main objective of fixing DDT URL pattern matching.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

re_path(r'^login/', handle_login_redirect),
# want api/v2/doesnotexist to return a 404, not match the ui urls,
# so use a negative lookahead assertion here
re_path(r'^(?!api/).*', include('awx.ui.urls', namespace='ui')),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment now separated from the code it describes

Low Severity

The comment on lines 37–38 ("so use a negative lookahead assertion here") originally sat directly above the re_path(r'^(?!api/).*', ...) pattern. After the move, the comment remains at the end of one urlpatterns block while the pattern it describes is now in a separate urlpatterns += block ~12 lines later. The word "here" no longer refers to anything nearby, making the comment misleading. The comment would be more useful if it traveled with the pattern it explains.

Additional Locations (1)
Fix in Cursor Fix in Web

@sonarqubecloud
Copy link

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant