Skip to content

See how your app actually fits together. An interactive, plain-English map of your codebase, drawn by Claude or Codex.

fix(scan): put Django urls included under a prefix at their full path

Rudy Celekli0ec05b125e65
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ae1f14..1312a1a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,9 @@
- Endpoints that change data are still always checked, and "Not a problem" is still there for anything Health can't work out.
- **FastAPI checks Health missed** (#7), fixed by @Bl0ck154: dependencies named like `metrics_guard`, a token in a `Header` parameter when the handler rejects a bad one, a Twilio-style signature check inside a helper, and `/readyz` and `/livez` as public health checks.
- **Health reads each Express route's own checks:** a sign-in check in front of a handler defined elsewhere (`router.post('/books', requireAuth, createBook)`) was missed, so the endpoint was reported as open to anyone. The other way round, a route could borrow the check of the route below it, and a handler whose name sounds like a check (`updateUser`) was taken for one, so some open endpoints weren't reported. Fixed by @rudycelekli.
+## Unreleased
+
+- **Django endpoints get their full address:** an app's `urls.py` included by the project (`path("api/orders/", include("orders.urls"))`) now puts its endpoints under that prefix, as `/api/orders/<int:pk>` rather than `/<int:pk>`, so the website's requests link to them. The include line itself is no longer listed as an endpoint, and the project's `urls.py` links to the app's. Fixed by @rudycelekli.
## 0.6.1 (2026-11-01)
diff --git a/docs/development.md b/docs/development.md
index 1b07964..767e502 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -83,6 +83,7 @@ The tests use Node's built-in test runner, so there's nothing to install (`npm t
| `health.test.mjs` | which endpoints Health calls open to anyone (FastAPI and Express samples in `fixtures/`) |
| `public-by-design.test.mjs` | what Health leaves alone because it's public on purpose (feeds, addresses a project publishes, cached responses, routes with nothing private, Payload CMS, tracker tokens, files a tool opens), each with a near miss it must still report |
| `stack-health.test.mjs` | Health's checks for Supabase row-level security, Firebase rules, Stripe webhook signatures, secret keys in public variables and CORS, with look-alikes each must leave alone, and a whole sample app done wrong and done right |
+| `django.test.mjs` | Django: an app's `urls.py` included under a prefix, and the website's requests matched to it |
| `firebase.test.mjs` | Firebase Cloud Functions: callables and onRequest functions as endpoints, the website's calls to them, Screens, Health, background functions (React + Firebase sample in `fixtures/`) |
| `blueprint.test.mjs` | a map planned from a PRD before any code exists: plan.json errors, endpoints and calls, Screens, the design review, refreshing and switching to the real code (sample PRD in `fixtures/`) |
| `blueprint-change.test.mjs` | changing a blueprint from the map: the agent's updated plan is checked, saved and highlighted, retried once when it fails the checks, and undone (stand-in CLI in `fixtures/fake-cli/`) |
diff --git a/skills/floorplan/scripts/lib/extract.mjs b/skills/floorplan/scripts/lib/extract.mjs
index 4b14efc..dc48516 100644
--- a/skills/floorplan/scripts/lib/extract.mjs
+++ b/skills/floorplan/scripts/lib/extract.mjs
@@ -374,9 +374,14 @@ function extractPy(src) {
for (const method of methods) routes.push({ method, path: m[3], var: m[1], line: at(m.index) });
}
// Django urls.py
- for (const m of all(/\b(?:re_)?path\(\s*r?["']([^"']*)["']\s*,\s*(?!include)/g, code)) routes.push({ method: 'ANY', path: '/' + m[1].replace(/^\^|\$$/g, ''), var: null, line: at(m.index), framework: 'django' });
+ for (const m of all(/\b(?:re_)?path\(\s*r?["']([^"']*)["']\s*,(?!\s*include\()/g, code)) routes.push({ method: 'ANY', path: '/' + m[1].replace(/^\^|\$$/g, ''), var: null, line: at(m.index), framework: 'django' });
const mounts = [];
+ // path('api/orders/', include('orders.urls')): that module's urls sit under the prefix, and this file uses it
+ for (const m of all(/\b(?:re_)?path\(\s*r?["']([^"']*)["']\s*,\s*include\(\s*\(?\s*["']([\w.]+)["']/g, code)) {
+ imports.push({ spec: m[2], names: [], line: at(m.index) });
+ mounts.push({ spec: m[2], prefix: m[1].replace(/^\^|\$$/g, ''), line: at(m.index) });
+ }
for (const m of all(/\b(register_blueprint|include_router|mount)\(\s*([A-Za-z_][\w.]*)/g, code)) {
// the call's arguments, up to its own closing bracket: dependencies=[Depends(x)] holds brackets of its own
let depth = 1, j = m.index + m[0].length;
diff --git a/tests/django.test.mjs b/tests/django.test.mjs
new file mode 100644
index 0000000..602d675
--- /dev/null
+++ b/tests/django.test.mjs
@@ -0,0 +1,37 @@
+// Django: an app's urls.py included under a prefix by the project's urls.py.
+import { test, after } from 'node:test';
+import assert from 'node:assert/strict';
+import path from 'node:path';
+import { makeProject, run, readJson, cleanup } from './helpers.mjs';
+
+const root = makeProject({
+ 'manage.py': '',
+ 'mysite/__init__.py': '',
+ 'mysite/urls.py': [
+ 'from django.urls import include, path, re_path',
+ 'urlpatterns = [',
+ ' path("api/orders/", include("orders.urls")),',
+ ' re_path(r"^api/shop/", include(("shop.urls", "shop"), namespace="shop")),',
+ ']',
+ ].join('\n'),
+ 'orders/__init__.py': '',
+ 'orders/urls.py': 'from django.urls import path\nfrom . import views\nurlpatterns = [\n path("", views.order_list),\n path("<int:pk>/", views.order_detail),\n]\n',
+ 'orders/views.py': 'def order_list(request): ...\ndef order_detail(request, pk): ...\n',
+ 'shop/__init__.py': '',
+ 'shop/urls.py': 'from django.urls import path\nfrom . import views\nurlpatterns = [path("cart/", views.cart)]\n',
+ 'shop/views.py': 'def cart(request): ...\n',
+ 'web/api.js': 'export const getOrder = (id) => fetch(`/api/orders/${id}/`);\n',
+});
+after(() => cleanup(root));
+
+test('urls included under a prefix get it, and the include line is not an endpoint itself', () => {
+ run('scan.mjs', root);
+ const scan = readJson(path.join(root, 'floorplan', '.cache', 'scan.json'));
+ assert.deepEqual(scan.routes.map((r) => `${r.file} ${r.path}`).sort(), [
+ 'orders/urls.py /api/orders',
+ 'orders/urls.py /api/orders/<int:pk>',
+ 'shop/urls.py /api/shop/cart',
+ ]);
+ assert.ok(scan.edges.some((e) => e.from === 'mysite/urls.py' && e.to === 'orders/urls.py'), 'expected the project urls to use the app urls');
+ assert.deepEqual(scan.http.map((h) => `${h.from} -> ${h.path}`), ['web/api.js -> /api/orders/<int:pk>']);
+});