From 66f96002864bbfd76e80f2f7d1a9d9093d8acb69 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Sat, 31 Jan 2026 21:18:02 +0100 Subject: [PATCH] fix: remove broken dev_tools router references after API route migration The dev_tools API routes were moved to the monitoring module, but several files still tried to import the non-existent admin_router. This caused warnings during app startup. Changes: - Remove _get_admin_router() from definition.py - Clear routes/__init__.py and routes/api/__init__.py of broken imports - Update exceptions.py to import from monitoring.exceptions - Update code_quality_service.py to import from monitoring.exceptions Co-Authored-By: Claude Opus 4.5 --- app/modules/dev_tools/definition.py | 19 +++++++------------ app/modules/dev_tools/exceptions.py | 5 ++--- app/modules/dev_tools/routes/__init__.py | 12 ++++++------ app/modules/dev_tools/routes/api/__init__.py | 12 ++++-------- .../dev_tools/routes/pages/__init__.py | 6 ++---- .../services/code_quality_service.py | 2 +- 6 files changed, 22 insertions(+), 34 deletions(-) diff --git a/app/modules/dev_tools/definition.py b/app/modules/dev_tools/definition.py index 31c59ec1..dab35690 100644 --- a/app/modules/dev_tools/definition.py +++ b/app/modules/dev_tools/definition.py @@ -16,14 +16,9 @@ from app.modules.base import ModuleDefinition from models.database.admin_menu_config import FrontendType -def _get_admin_router(): - """Lazy import of admin router to avoid circular imports.""" - from app.modules.dev_tools.routes.api.admin import admin_router - - return admin_router - - # Dev-Tools module definition +# Note: API routes (code quality, tests) have been moved to monitoring module. +# This module retains models, services, and page routes only. dev_tools_module = ModuleDefinition( code="dev-tools", name="Developer Tools", @@ -81,13 +76,13 @@ dev_tools_module = ModuleDefinition( def get_dev_tools_module_with_routers() -> ModuleDefinition: """ - Get dev-tools module with routers attached. + Get dev-tools module definition. - This function attaches the routers lazily to avoid circular imports - during module initialization. + Note: API routes have been moved to monitoring module. + This module has no routers to attach. """ - dev_tools_module.admin_router = _get_admin_router() - # No vendor router for internal modules + # No routers - API routes are now in monitoring module + dev_tools_module.admin_router = None dev_tools_module.vendor_router = None return dev_tools_module diff --git a/app/modules/dev_tools/exceptions.py b/app/modules/dev_tools/exceptions.py index 375ac0b0..670814e9 100644 --- a/app/modules/dev_tools/exceptions.py +++ b/app/modules/dev_tools/exceptions.py @@ -12,9 +12,8 @@ from app.exceptions.base import ( ResourceNotFoundException, ) -# Re-export code quality exceptions from legacy location -# This avoids circular imports since app/exceptions/__init__.py imports code_quality.py -from app.exceptions.code_quality import ( +# Re-export code quality exceptions from their module location +from app.modules.monitoring.exceptions import ( ViolationNotFoundException, ScanNotFoundException, ScanExecutionException, diff --git a/app/modules/dev_tools/routes/__init__.py b/app/modules/dev_tools/routes/__init__.py index 02004898..80df91fa 100644 --- a/app/modules/dev_tools/routes/__init__.py +++ b/app/modules/dev_tools/routes/__init__.py @@ -2,15 +2,15 @@ """ Dev-Tools module route registration. -This module provides dev-tools routes with module-based access control. +This module provides dev-tools page routes for admin pages. Structure: -- routes/api/ - REST API endpoints (code quality, tests) - routes/pages/ - HTML page rendering (component library, icons) -Note: Dev-tools is an internal module (admin-only), so there is no vendor router. +Note: API routes (code quality, tests) have been moved to the monitoring module. +Dev-tools is an internal module (admin-only), so there is no vendor router. """ -from app.modules.dev_tools.routes.api import admin_router - -__all__ = ["admin_router"] +# No routers to export - API routes moved to monitoring module +# Page routes are auto-discovered from routes/pages/admin.py +__all__ = [] diff --git a/app/modules/dev_tools/routes/api/__init__.py b/app/modules/dev_tools/routes/api/__init__.py index 78a181ce..ca255c38 100644 --- a/app/modules/dev_tools/routes/api/__init__.py +++ b/app/modules/dev_tools/routes/api/__init__.py @@ -2,13 +2,9 @@ """ Dev-Tools module API routes. -Provides REST API endpoints for code quality and test running: -- Admin API: Code quality scans, violations, test execution - -Note: Dev-tools is an internal module, so there are no vendor routes. -Currently re-exports routes from the legacy location. +Note: Code quality and test running routes have been moved to the monitoring module. +The dev_tools module keeps models but routes are now in monitoring. """ -from app.modules.dev_tools.routes.api.admin import admin_router - -__all__ = ["admin_router"] +# No routes exported - code quality and tests are in monitoring module +__all__ = [] diff --git a/app/modules/dev_tools/routes/pages/__init__.py b/app/modules/dev_tools/routes/pages/__init__.py index 036b4041..cb59ebae 100644 --- a/app/modules/dev_tools/routes/pages/__init__.py +++ b/app/modules/dev_tools/routes/pages/__init__.py @@ -1,4 +1,2 @@ -# Page routes will be added here -# TODO: Add HTML page routes for admin/vendor dashboards - -__all__ = [] +# app/modules/dev_tools/routes/pages/__init__.py +"""Dev tools module page routes.""" diff --git a/app/modules/dev_tools/services/code_quality_service.py b/app/modules/dev_tools/services/code_quality_service.py index 66c8468d..30bf4ae0 100644 --- a/app/modules/dev_tools/services/code_quality_service.py +++ b/app/modules/dev_tools/services/code_quality_service.py @@ -12,7 +12,7 @@ from datetime import datetime, UTC from sqlalchemy import desc, func from sqlalchemy.orm import Session -from app.exceptions import ( +from app.modules.monitoring.exceptions import ( ScanParseException, ScanTimeoutException, ViolationNotFoundException,