{"record":{"id":"f70c667f4ac49d5e","repo":"slimtoolkit/slim","slug":"cannot-create-execution-cannot-read-command-file","errorCode":null,"errorMessage":"cannot create execution - cannot read command file %q: %w","messagePattern":"cannot create execution - cannot read command file %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/execution/standalone.go","lineNumber":52,"sourceCode":"\t// fsutil.Touch() creates (potentially missing) folder(s).\n\tif err := fsutil.Touch(eventFileName); err != nil {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"cannot create execution - touch event file %q failed: %w\",\n\t\t\teventFileName, err,\n\t\t)\n\t}\n\n\teventFile, err := os.OpenFile(eventFileName, os.O_APPEND|os.O_WRONLY|os.O_SYNC, 0644)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"cannot create execution - open event file %q failed: %w\",\n\t\t\teventFileName, err,\n\t\t)\n\t}\n\n\tcmd, err := readCommandFile(commandFileName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"cannot create execution - cannot read command file %q: %w\",\n\t\t\tcommandFileName, err,\n\t\t)\n\t}\n\n\tcommandCh := make(chan command.Message, 10)\n\tcommandCh <- &cmd\n\n\tgo control.HandleControlCommandQueue(ctx, commandFileName, commandCh)\n\n\treturn &standaloneExe{\n\t\thookExecutor: hookExecutor{\n\t\t\tctx: ctx,\n\t\t\tcmd: lifecycleHookCommand,\n\t\t},\n\t\tcommandCh: commandCh,\n\t\teventFile: eventFile,\n\t}, nil","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/execution/standalone.go#L34-L70","documentation":"NewStandalone reads the sensor's start command (a command.StartMonitor JSON) from commandFileName via readCommandFile. Any failure reading that file (missing, unreadable, I/O error) is surfaced as this wrapped error, aborting execution creation.","triggerScenarios":"Calling NewStandalone with a commandFileName that does not exist, is unreadable by the current user, or cannot be read due to I/O errors (e.g. missing volume mount).","commonSituations":"The instrumentor was supposed to write the command file into a shared volume that was not mounted; command file deleted before the sensor started; wrong path passed to newExecution.","solutions":["Verify commandFileName exists and is readable (ls -l) before starting the sensor.","Ensure the volume containing the command file is mounted into the sensor container at the expected path.","Fix the underlying error in the wrapped %w message (permissions, ENOENT, etc.)."],"exampleFix":"// before\niface, err := execution.NewStandalone(\"/missing/cmd\", eventFile, hook)\n// after\n// mount the command file first, then:\niface, err := execution.NewStandalone(\"/var/run/sensor/cmd\", eventFile, hook)","handlingStrategy":"validation","validationCode":"func commandFileReady(path string) error {\n    fi, err := os.Stat(path)\n    if err != nil { return fmt.Errorf(\"command file missing: %w\", err) }\n    if fi.Size() == 0 { return fmt.Errorf(\"command file empty\") }\n    f, err := os.Open(path)\n    if err != nil { return err }\n    return f.Close()\n}","typeGuard":"func isMissingFileError(err error) bool {\n    return errors.Is(err, fs.ErrNotExist)\n}","tryCatchPattern":"exec, err := execution.NewStandalone(commandFile, eventFile, hook)\nif err != nil && strings.Contains(err.Error(), \"cannot read command file\") {\n    return fmt.Errorf(\"sensor startup aborted, command file unreadable: %w\", err)\n}","preventionTips":["Use an initContainer or entrypoint wait-loop that blocks until the command file exists.","Mount the shared volume containing the command file at the exact configured path.","Keep the command file path in one place in config to avoid typos.","Log the resolved absolute path at startup for easy diagnosis."],"tags":["filesystem","file-read","configuration","standalone-execution"],"backgroundTag":"file-not-found","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}