{"record":{"id":"b4b8c4f77c55a1ee","repo":"slimtoolkit/slim","slug":"run-sensor-without-monitor-failed-w","errorCode":null,"errorMessage":"run sensor without monitor failed: %w","messagePattern":"run sensor without monitor failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/controlled/controlled.go","lineNumber":97,"sourceCode":"\n\treturn err\n}\n\nfunc (s *Sensor) run() error {\n\tlog.Info(\"sensor: waiting for commands...\")\n\n\tfor {\n\t\tmon, err := s.runWithoutMonitor()\n\t\tif err != nil {\n\t\t\ts.exe.HookMonitorFailed()\n\t\t\ts.exe.PubEvent(event.StartMonitorFailed,\n\t\t\t\t&event.StartMonitorFailedData{\n\t\t\t\t\tComponent: event.ComMonitorRunner, //TODO: need to get to the real component\n\t\t\t\t\tState:     s.exe.State(),\n\t\t\t\t\tErrors:    []string{err.Error()},\n\t\t\t\t})\n\n\t\t\treturn fmt.Errorf(\"run sensor without monitor failed: %w\", err)\n\t\t}\n\n\t\tif mon == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\ts.exe.PubEvent(event.StartMonitorDone)\n\n\t\tif err := s.runWithMonitor(mon); err != nil {\n\t\t\treturn fmt.Errorf(\"run sensor with monitor failed: %w\", err)\n\t\t}\n\n\t\ts.exe.HookMonitorPostShutdown()\n\t\ts.exe.PubEvent(event.StopMonitorDone)\n\t}\n}\n\nfunc (s *Sensor) runWithoutMonitor() (monitor.CompositeMonitor, error) {","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/controlled/controlled.go#L79-L115","documentation":"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.","triggerScenarios":"run() is invoked and monitor startup fails, causing the StartMonitorFailed event and a non-nil err, so runWithoutMonitor aborts.","commonSituations":"Bad monitor configuration, missing artifacts env, driver/loader failures when the monitor component cannot initialize.","solutions":["Read the wrapped error and the StartMonitorFailedData.Errors for the root cause","Verify monitor prerequisites (artifacts env, permissions, kernel support) before starting","Fix the underlying monitor startup error surfaced in the event"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify monitor prerequisites before run:\n// writable artifacts dir exists and mount point is accessible\nif _, err := os.Stat(artifactsDir); err != nil { return err }","typeGuard":null,"tryCatchPattern":"err := sensor.Run(ctx)\nif err != nil {\n\troot := err\n\tfor errors.Unwrap(root) != nil { root = errors.Unwrap(root) }\n\tlog.Printf(\"sensor run failed: %v (root: %v)\", err, root)\n}","preventionTips":["Subscribe to StartMonitorFailed events to capture root-cause errors array","Pre-validate artifacts env and permissions before Run","Use errors.Is/As on the wrapped chain"],"tags":["go","sensor","monitor","error-wrapping"],"backgroundTag":"monitor-start-failed","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}