{"record":{"id":"6bb4ad5af8769454","repo":"slimtoolkit/slim","slug":"run-sensor-with-monitor-failed-w","errorCode":null,"errorMessage":"run sensor with monitor failed: %w","messagePattern":"run sensor with monitor failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/controlled/controlled.go","lineNumber":107,"sourceCode":"\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) {\n\tticker := time.NewTicker(5 * time.Second)\n\tdefer ticker.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase cmd := <-s.exe.Commands():\n\t\t\tlog.Debugf(\"sensor: new command => %+v\", cmd)\n\n\t\t\tswitch typedCmd := cmd.(type) {\n\t\t\tcase *command.StartMonitor:","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/controlled/controlled.go#L89-L125","documentation":"run() starts the composite monitor and then delegates to runWithMonitor, which runs until the monitor finishes. If runWithMonitor returns an error, run wraps it with this message. The wrapped error originates deeper (monitor failure, unexpected command, reporting).","triggerScenarios":"s.runWithMonitor(mon) returns any error during a monitored sensor run — e.g. monitor error, unexpected stop command, or result-processing failure.","commonSituations":"Monitor crashing mid-capture, control commands arriving out of order, downstream artifact processing failures.","solutions":["Unwrap with errors.Unwrap / %w chain to find the root cause","Check monitor logs and its Status() report for the failure","Re-run with debug logging around monitor lifecycle events"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := sensor.Run(ctx)\nvar wrapped interface{ Unwrap() error }\nif errors.As(err, &wrapped) {\n\tlog.Printf(\"monitor run root cause: %v\", errors.Unwrap(err))\n}","preventionTips":["Enable debug logging across the monitor lifecycle","Check that control commands are sent in correct order","Inspect monitor Status/report artifacts after failure"],"tags":["go","sensor","monitor","error-wrapping"],"backgroundTag":"monitor-run-failed","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}