slimtoolkit/slim · error

run sensor without monitor failed: %w

Error message

run sensor without monitor failed: %w

What it means

The controlled sensor's run loop starts the sensor without a monitor; when StartMonitorFailed is published (monitor setup failed) the underlying error is wrapped with this message and returned to the state machine caller. It is a wrapper: the real cause is in the %w-wrapped error and the StartMonitorFailedData event.

Source

Thrown at pkg/app/sensor/controlled/controlled.go:97

	return err
}

func (s *Sensor) run() error {
	log.Info("sensor: waiting for commands...")

	for {
		mon, err := s.runWithoutMonitor()
		if err != nil {
			s.exe.HookMonitorFailed()
			s.exe.PubEvent(event.StartMonitorFailed,
				&event.StartMonitorFailedData{
					Component: event.ComMonitorRunner, //TODO: need to get to the real component
					State:     s.exe.State(),
					Errors:    []string{err.Error()},
				})

			return fmt.Errorf("run sensor without monitor failed: %w", err)
		}

		if mon == nil {
			return nil
		}

		s.exe.PubEvent(event.StartMonitorDone)

		if err := s.runWithMonitor(mon); err != nil {
			return fmt.Errorf("run sensor with monitor failed: %w", err)
		}

		s.exe.HookMonitorPostShutdown()
		s.exe.PubEvent(event.StopMonitorDone)
	}
}

func (s *Sensor) runWithoutMonitor() (monitor.CompositeMonitor, error) {

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Read the wrapped error and the StartMonitorFailedData.Errors for the root cause
  2. Verify monitor prerequisites (artifacts env, permissions, kernel support) before starting
  3. Fix the underlying monitor startup error surfaced in the event
Defensive patterns

Strategy: try-catch

Validate before calling

// verify monitor prerequisites before run:
// writable artifacts dir exists and mount point is accessible
if _, err := os.Stat(artifactsDir); err != nil { return err }

Try / catch

err := sensor.Run(ctx)
if err != nil {
	root := err
	for errors.Unwrap(root) != nil { root = errors.Unwrap(root) }
	log.Printf("sensor run failed: %v (root: %v)", err, root)
}

Prevention

When it happens

Trigger: run() is invoked and monitor startup fails, causing the StartMonitorFailed event and a non-nil err, so runWithoutMonitor aborts.

Common situations: Bad monitor configuration, missing artifacts env, driver/loader failures when the monitor component cannot initialize.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/b4b8c4f77c55a1ee. Report an issue: GitHub.