{"record":{"id":"958ea702c6f72256","repo":"slimtoolkit/slim","slug":"sensor-artifact-getnuxtconfig-error-reading-f","errorCode":null,"errorMessage":"sensor: artifact - getNuxtConfig - error reading file => %s","messagePattern":"sensor: artifact - getNuxtConfig - error reading file => (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/artifact/artifact.go","lineNumber":3022,"sourceCode":"\n\treturn nil\n}\n\ntype nuxtDirs struct {\n\tBuild string\n\tDist  string\n}\n\nfunc getNuxtConfig(path string) (*nuxtDirs, error) {\n\tif _, err := os.Stat(path); err != nil && os.IsNotExist(err) {\n\t\tlog.Debugf(\"sensor: monitor - getNuxtConfig - err stat => %s - %s\", path, err.Error())\n\t\treturn nil, fmt.Errorf(\"sensor: artifact - getNuxtConfig - error getting file => %s\", path)\n\t}\n\n\tdat, err := os.ReadFile(path)\n\tif err != nil {\n\t\tlog.Debugf(\"sensor: monitor - getNuxtConfig - err reading file => %s - %s\", path, err.Error())\n\t\treturn nil, fmt.Errorf(\"sensor: artifact - getNuxtConfig - error reading file => %s\", path)\n\t}\n\n\tlog.Tracef(\"sensor: monitor - getNuxtConfig(%s) - %s\", path, string(dat))\n\n\tnuxt := nuxtDirs{\n\t\tBuild: nuxtDefaultBuildDir,\n\t\tDist:  fmt.Sprintf(\"%s/%s\", nuxtDefaultBuildDir, nuxtDefaultDistDir),\n\t}\n\n\t/*\n\t\ttodo: need more test apps to verify this part of the code\n\t\tvm := otto.New()\n\t\tvm.Run(dat)\n\n\t\tif value, err := vm.Get(nuxtBuildDirKey); err == nil {\n\t\t\tif v, err := value.ToString(); err == nil {\n\t\t\t\tnuxt.Build = v\n\t\t\t} else {","sourceCodeStart":3004,"sourceCodeEnd":3040,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/artifact/artifact.go#L3004-L3040","documentation":"After the stat check passes, getNuxtConfig reads the nuxt.config file with os.ReadFile. If the read fails (permissions, I/O error, file removed between stat and read), it logs the details at debug level and returns this error naming the path.","triggerScenarios":"os.ReadFile on an existing nuxt.config path fails — file is a directory/symlink target missing, permission denied for the sensor's user, or the file was deleted between the Stat call and the ReadFile call.","commonSituations":"Sensor running as a different user than the app files' owner (no read permission); encrypted or bind-mounted volumes with restrictive modes; race where the build pipeline removes the config during scanning.","solutions":["Check the debug log for the exact ReadFile error (EACCES vs ENOENT vs EISDIR).","Grant read permission on the config file/directory to the sensor's user.","Confirm the path is a regular file, not a directory or dangling symlink.","Retry the scan if the file was transiently removed during a build."],"exampleFix":"// before\ndat, err := os.ReadFile(path)\n// after\ndat, err := os.ReadFile(path)\nif err != nil && errors.Is(err, os.ErrPermission) {\n    return nil, fmt.Errorf(\"sensor: artifact - getNuxtConfig - permission denied reading %s: %w\", path, err)\n}","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(configPath)\nif err != nil {\n    return fmt.Errorf(\"config inaccessible: %w\", err)\n}\nif !fi.Mode().IsRegular() {\n    return fmt.Errorf(\"%s is not a regular file\", configPath)\n}\nf, err := os.Open(configPath)\nif err != nil {\n    return fmt.Errorf(\"no read permission on %s: %w\", configPath, err)\n}\nf.Close()","typeGuard":null,"tryCatchPattern":"nuxt, err := getNuxtConfig(configPath)\nif err != nil {\n    if strings.Contains(err.Error(), \"error reading file\") {\n        return fmt.Errorf(\"fix permissions on %s for the sensor user: %w\", configPath, err)\n    }\n    return err\n}","preventionTips":["Run the sensor with a user that has read access to app files","Avoid restrictive bind mounts/umasks on scanned directories","Don't delete config files while a scan is in progress"],"tags":["nuxt","file-read","permissions","sensor"],"backgroundTag":"file-read-failed","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}