{"record":{"id":"845dc8ba7670296b","repo":"golangci/golangci-lint","slug":"file-s-open-w","errorCode":null,"errorMessage":"file %s open: %w","messagePattern":"file (.+?) open: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/internal/configuration.go","lineNumber":103,"sourceCode":"\n\t// Version of the module.\n\t// Only for module available through a Go proxy.\n\tVersion string `yaml:\"version,omitempty\"`\n\n\t// Path to the local module.\n\t// Only for local module.\n\tPath string `yaml:\"path,omitempty\"`\n}\n\nfunc LoadConfiguration() (*Configuration, error) {\n\tconfigFilePath, err := findConfigurationFile()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"file %s not found: %w\", configFilePath, err)\n\t}\n\n\tfile, err := os.Open(configFilePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"file %s open: %w\", configFilePath, err)\n\t}\n\n\tdefer func() { _ = file.Close() }()\n\n\tvar cfg Configuration\n\n\terr = yaml.NewDecoder(file).Decode(&cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"YAML decoding: %w\", err)\n\t}\n\n\treturn &cfg, nil\n}\n\nfunc findConfigurationFile() (string, error) {\n\tentries, err := os.ReadDir(\".\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"read directory: %w\", err)","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/internal/configuration.go#L85-L121","documentation":"After findConfigurationFile succeeds, LoadConfiguration opens the located file with os.Open; this wrapper reports 'file %s open'. The config path was found in the directory listing but could not be opened for reading, so the wrapped error is a *os.PathError (usually EACCES or a race where the file disappeared).","triggerScenarios":"findConfigurationFile matched the filename but os.Open(configFilePath) failed: no read permission on the file, it is a directory or symlink to something unreadable, or it was deleted between listing and opening.","commonSituations":"Config file committed with 000/600 permissions while CI runs as another user, config checked out with restrictive umask, a directory named like the config file, or a broken symlink named config.yaml.","solutions":["Check and fix permissions: chmod +r <configFile> (and ensure parent directories allow traversal)","Confirm the matched name is a regular readable file, not a directory or broken symlink (ls -la)","Re-run if a concurrent process may have removed the file between listing and open","If permissions cannot be relaxed, run the command as a user with read access"],"exampleFix":"// before\n-rw------- 1 ci ci config.yaml   # CI user cannot read\n// after\nchmod 644 config.yaml","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(configFilePath); err != nil {\n    return fmt.Errorf(\"config %s unreadable: %w\", configFilePath, err)\n} else if !fi.Mode().IsRegular() {\n    return fmt.Errorf(\"config %s is not a regular file\", configFilePath)\n} else if fi.Mode().Perm()&0o400 == 0 {\n    return fmt.Errorf(\"config %s has no read permission for current user\", configFilePath)\n}","typeGuard":null,"tryCatchPattern":"cfg, err := LoadConfiguration()\nif err != nil {\n    var perr *fs.PathError\n    if errors.As(err, &perr) && errors.Is(perr, fs.ErrPermission) {\n        log.Fatalf(\"config %s: permission denied — chmod +r or run as a user with access\", perr.Path)\n    }\n    return err\n}","preventionTips":["Commit config files with 644 permissions; avoid restrictive umasks in CI","Never name a directory like the config file or leave broken symlinks at that name","Verify the matched file is a regular readable file after discovery","If running as a different user in CI, confirm it can read the checked-out config"],"tags":["go","config","permissions","file-io"],"backgroundTag":"permission-denied","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}