{"record":{"id":"6512acf98b92cbdf","repo":"ruvnet/RuView","slug":"service-not-found-service-name","errorCode":null,"errorMessage":"Service not found: {service_name}","messagePattern":"Service not found: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/services/orchestrator.py","lineNumber":273,"sourceCode":"            \n            if self.pose_service and hasattr(self.pose_service, 'shutdown'):\n                await self.pose_service.shutdown()\n            \n            if self.hardware_service and hasattr(self.hardware_service, 'shutdown'):\n                await self.hardware_service.shutdown()\n            \n            logger.info(\"Application services shut down\")\n            \n        except Exception as e:\n            logger.error(f\"Error shutting down application services: {e}\")\n    \n    async def restart_service(self, service_name: str):\n        \"\"\"Restart a specific service.\"\"\"\n        logger.info(f\"Restarting service: {service_name}\")\n        \n        service = self._services.get(service_name)\n        if not service:\n            raise ValueError(f\"Service not found: {service_name}\")\n        \n        try:\n            # Stop service\n            if hasattr(service, 'stop'):\n                await service.stop()\n            elif hasattr(service, 'shutdown'):\n                await service.shutdown()\n            \n            # Reinitialize service\n            if hasattr(service, 'initialize'):\n                await service.initialize()\n            \n            # Start service\n            if hasattr(service, 'start'):\n                await service.start()\n            \n            logger.info(f\"Service restarted successfully: {service_name}\")\n            ","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/services/orchestrator.py#L255-L291","documentation":"Orchestrator.restart_service() looks up service_name in the internal _services registry, which is populated when services are registered/initialized at application startup. An unregistered name raises ValueError before any stop/initialize work happens. So the name is simply not a known service: either a typo, a service that failed to register, or a lookup after the registry was cleared during shutdown.","triggerScenarios":"Calling restart_service('pose') when the registry key is 'pose_service'; restarting a service whose registration failed during startup; calling restart after orchestrator shutdown emptied _services; using a display label instead of the registry key.","commonSituations":"Admin endpoints or ops scripts guessing service names; refactors that rename registry keys while old scripts persist; environment-dependent service sets (redis disabled, so 'redis_service' never registered).","solutions":["Enumerate registered names before restarting: 'list(orchestrator._services.keys())' (or the orchestrator's listing API) and use an exact key.","Ensure application startup completed so all intended services registered.","Fix the caller to use the canonical registry key, matching case exactly.","If a conditional service (e.g. redis) is optional, make restart calls conditional on it being registered."],"exampleFix":"# before\nawait orchestrator.restart_service('pose')  # ValueError: Service not found\n\n# after\nregistered = list(orchestrator._services.keys())\nif 'pose_service' not in registered:\n    raise ValueError(f'unknown service; registered: {registered}')\nawait orchestrator.restart_service('pose_service')","handlingStrategy":"validation","validationCode":"registered = list(orchestrator._services)\nif service_name not in registered:\n    raise ValueError(f'unknown service {service_name}; registered: {registered}')\nawait orchestrator.restart_service(service_name)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Publish the set of registered service names (from _services) to ops tooling and only restart keys from that set.","Make optional services (e.g. redis) restart-conditional on registration.","Use exact registry keys in scripts; add a dry-run listing mode to admin endpoints."],"tags":["orchestrator","service","lifecycle","validation"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}