diff --git a/app/main.py b/app/main.py index e855f14..086b644 100644 --- a/app/main.py +++ b/app/main.py @@ -497,23 +497,15 @@ def create_app() -> FastAPI: router = getattr(router_module, route_def.router_attr) # Check if this route definition is public (no auth required) is_public = getattr(route_def, "is_public", False) - from starlette.routing import WebSocketRoute if is_public: # Public routes: no auth dependency, no plugin check app.include_router(router) logger.info(f"Registered PUBLIC routes for {plugin_name}: {route_def.module}") continue plugin_dep = Depends(require_active_plugin(plugin_name)) - for route in router.routes: - if isinstance(route, WebSocketRoute): - if not hasattr(route, 'dependencies'): - route.dependencies = [] - route.dependencies.append(plugin_dep) - continue - if not hasattr(route, 'dependencies'): - route.dependencies = [] - route.dependencies.append(plugin_dep) - app.include_router(router) + # Use include_router with dependencies to avoid mutating + # the shared module-level router object (which tests reuse) + app.include_router(router, dependencies=[plugin_dep]) except Exception as exc: logger.error(f"Failed to register route {route_def.module}.{route_def.router_attr}: {exc}") break