{"record":{"id":"c01f8ef8ad563cc1","repo":"slimtoolkit/slim","slug":"failed-to-prepare-artifacts-env-w","errorCode":null,"errorMessage":"failed to prepare artifacts env: %w","messagePattern":"failed to prepare artifacts env: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/controlled/controlled.go","lineNumber":144,"sourceCode":"\t\t\t\treturn s.startMonitor(typedCmd)\n\n\t\t\tcase *command.ShutdownSensor:\n\t\t\t\treturn nil, nil // Clean exit\n\n\t\t\tdefault:\n\t\t\t\tlog.Warn(\"sensor: ignoring unknown or unexpected command => \", cmd)\n\t\t\t} // eof: type switch\n\n\t\tcase <-ticker.C:\n\t\t\tlog.Debug(\".\")\n\t\t} // eof: select\n\t}\n}\n\nfunc (s *Sensor) startMonitor(cmd *command.StartMonitor) (monitor.CompositeMonitor, error) {\n\tif err := s.artifactor.PrepareEnv(cmd); err != nil {\n\t\tlog.WithError(err).Error(\"sensor: artifactor.PrepareEnv() failed\")\n\t\treturn nil, fmt.Errorf(\"failed to prepare artifacts env: %w\", err)\n\t}\n\n\torigPaths, err := s.artifactor.GetCurrentPaths(s.mountPoint, cmd.Excludes)\n\tif err != nil {\n\t\tlog.WithError(err).Error(\"sensor: artifactor.GetCurrentPaths() failed\")\n\t\treturn nil, fmt.Errorf(\"failed to enumerate current paths: %w\", err)\n\t}\n\n\ts.exe.HookMonitorPreStart()\n\n\tmon, err := s.newMonitor(\n\t\ts.ctx,\n\t\tcmd,\n\t\ts.workDir,\n\t\ts.del,\n\t\ts.artifactor.ArtifactsDir(),\n\t\ts.mountPoint,\n\t\torigPaths,","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/controlled/controlled.go#L126-L162","documentation":"startMonitor first asks the artifactor to prepare the artifacts environment for the StartMonitor command. If artifactor.PrepareEnv(cmd) fails, the error is logged and wrapped with this message. Preparation includes creating directories, symlinks and device filtering via the helpers in artifact.go.","triggerScenarios":"startMonitor is called (from runWithoutMonitor path) and PrepareEnv fails — e.g. cannot create artifact directories, stat helper errors (see errors 120/121), permission denied on mount point.","commonSituations":"Read-only or unwritable artifact paths, wrong mountPoint, disk full, non-Linux Sys() assertion failures during path enumeration.","solutions":["Inspect the logged wrapped error from PrepareEnv for the root cause","Verify the artifact output directories are writable and the mountPoint is correct","Check disk space and permissions on the artifacts env paths"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before starting monitor, ensure artifacts env is writable\nfor _, dir := range []string{artifactsDir, mountPoint} {\n\tif fi, err := os.Stat(dir); err != nil || !fi.IsDir() {\n\t\tlog.Fatalf(\"invalid path %s: %v\", dir, err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"mon, err := startMonitor(cmd)\nif err != nil && strings.Contains(err.Error(), \"failed to prepare artifacts env\") {\n\tlog.Printf(\"env prep root cause: %v\", errors.Unwrap(err))\n}","preventionTips":["Pre-create artifact directories with correct permissions","Check disk space before runs","Keep mountPoint configuration accurate"],"tags":["go","sensor","artifacts","monitor"],"backgroundTag":"artifacts-env-preparation-failed","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}