ruvnet/RuView · error · ValueError

Service not found: {service_name}

Error message

Service not found: {service_name}

What it means

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.

Source

Thrown at archive/v1/src/services/orchestrator.py:273

            
            if self.pose_service and hasattr(self.pose_service, 'shutdown'):
                await self.pose_service.shutdown()
            
            if self.hardware_service and hasattr(self.hardware_service, 'shutdown'):
                await self.hardware_service.shutdown()
            
            logger.info("Application services shut down")
            
        except Exception as e:
            logger.error(f"Error shutting down application services: {e}")
    
    async def restart_service(self, service_name: str):
        """Restart a specific service."""
        logger.info(f"Restarting service: {service_name}")
        
        service = self._services.get(service_name)
        if not service:
            raise ValueError(f"Service not found: {service_name}")
        
        try:
            # Stop service
            if hasattr(service, 'stop'):
                await service.stop()
            elif hasattr(service, 'shutdown'):
                await service.shutdown()
            
            # Reinitialize service
            if hasattr(service, 'initialize'):
                await service.initialize()
            
            # Start service
            if hasattr(service, 'start'):
                await service.start()
            
            logger.info(f"Service restarted successfully: {service_name}")
            

View on GitHub (pinned to 4685618388)

Solutions

  1. Enumerate registered names before restarting: 'list(orchestrator._services.keys())' (or the orchestrator's listing API) and use an exact key.
  2. Ensure application startup completed so all intended services registered.
  3. Fix the caller to use the canonical registry key, matching case exactly.
  4. If a conditional service (e.g. redis) is optional, make restart calls conditional on it being registered.

Example fix

# before
await orchestrator.restart_service('pose')  # ValueError: Service not found

# after
registered = list(orchestrator._services.keys())
if 'pose_service' not in registered:
    raise ValueError(f'unknown service; registered: {registered}')
await orchestrator.restart_service('pose_service')
Defensive patterns

Strategy: validation

Validate before calling

registered = list(orchestrator._services)
if service_name not in registered:
    raise ValueError(f'unknown service {service_name}; registered: {registered}')
await orchestrator.restart_service(service_name)

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16). Data as JSON: /api/errors/6512acf98b92cbdf. Report an issue: GitHub.