Skip to content

fix: diagnostic false positives + Inertia 307 strip (#70) - #88

Merged
antosubash merged 3 commits into
mainfrom
claude/fix-all-issues-v1BnN
Apr 30, 2026
Merged

fix: diagnostic false positives + Inertia 307 strip (#70)#88
antosubash merged 3 commits into
mainfrom
claude/fix-all-issues-v1BnN

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

Three concrete framework fixes surfaced by make doctor and the open issue tracker. Many of the issues filed in #65#86 were already addressed in #87 (merged); this PR cleans up the remaining real problems I could verify in this repo.

SM003 false positive — cross-file PAGE constants

make doctor falsely flagged feature_flags/pages/Browse.tsx as orphan because the AST scanner only resolved inertia.render(NAME) constants defined in the same .py file. feature_flags defines PAGE_BROWSE in constants.py and uses it in endpoints/views.py, so the const lookup missed.

_iter_render_components now accepts an extra_consts registry, and _find_render_calls builds one across every .py file in the module's source tree before walking renders. Truly orphan pages still fire SM003.

SM019 — register_permissions is sufficient

The Permissions module surfaces its only views (RoleEdit, UserEdit) as deep-link edit pages reached from buttons inside the Users admin page. It registers permissions but no menu items. SM019 was firing on every boot.

Per the original issue (#85): a module is "silently invisible" only when admins can reach it through neither the sidebar nor the role editor. Loosened the check so registering either menu items or permissions silences the warning. Updated the diagnostic message and CLAUDE.md accordingly.

#70 — bare-prefix view alias

view_prefix="/foo" + @router.get("/") mounts at /foo/. A request to /foo (no slash) hits FastAPI's redirect_slashes=True 307, and httpx strips X-Inertia on follow — every Inertia link to a bare-prefix landing page broke.

wire_module_routes now auto-clones any view route at prefix + "/" to prefix (include_in_schema=False). Same handler, no redirect, X-Inertia survives. Confirmed via TestRouteRegistration::test_expected_routes_registered that /dashboard and /dashboard/ are both registered.

Issues not addressed here

Test plan

  • make doctor — clean, 0 errors / 0 warnings (was 2 warnings: SM003 FeatureFlags/Browse, SM019 Permissions)
  • uv run pytest --ignore=tests/e2e — 1044 passed
  • uv run ruff check framework/ modules/ — clean
  • uv run ruff format --check framework/ modules/ — clean
  • New tests: TestSm003PageRenderResolution (2), test_silent_when_permissions_registered, /dashboard bare-prefix assertion in test_expected_routes_registered

Generated by Claude Code

claude added 2 commits April 30, 2026 13:28
- SM003 now resolves PAGE_X string constants imported from sibling files
  (e.g. feature_flags PAGE_BROWSE in constants.py used in views.py),
  eliminating the false orphan-page warning that fired every doctor run.
- SM019 no longer warns when a module registers permissions but no menu
  items. Modules whose views are sub-pages of another module (e.g.
  Permissions' RoleEdit/UserEdit reached from Users admin) stay
  discoverable via the role editor without needing a sidebar entry.
- wire_module_routes auto-mounts a bare-prefix alias for view routes at
  '/'. FastAPI's redirect_slashes 307 caused httpx to strip X-Inertia on
  follow, breaking Inertia navigation; the alias serves the same handler
  directly. Closes #70.
CI's 300-line cap was tripped by the diagnostic + app-builder changes
in the previous commit. Split by responsibility, no behaviour change:

- diagnostics/_pages.py — orphan/phantom-page detection, render-call
  resolution, and the cross-file PAGE constant collector. Test now
  imports the module-level helpers directly instead of poking
  ModuleDiagnostics' private methods.
- _phase_helpers.py — gains wire_module_routes, including the
  bare-prefix view-route alias logic. app_builder.py re-imports it.
@antosubash
antosubash marked this pull request as ready for review April 30, 2026 16:36
…hecks

Apply review findings from /simplify:

- _pages.py parses each .py file once. Cross-file consts and render-call
  scanning share the parsed trees instead of rglob+ast.parse running twice.
- _module_level_str_consts replaces the duplicated isinstance ladder that
  in-file and cross-file collectors both ran.
- check_orphan_pages and check_phantom_renders merge into check_pages —
  one collect_tsx_pages call covers both directions of the diff.
- SM019 if-chain flattens to a single boolean.
- Trim narration in tests; the docstring on wire_module_routes already
  carries the X-Inertia rationale.
@antosubash
antosubash merged commit df9121f into main Apr 30, 2026
10 checks passed
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.

2 participants