{"record":{"id":"15df6c56de508636","repo":"thanos-io/thanos","slug":"dir-is-not-accessible","errorCode":null,"errorMessage":"Dir is not accessible.","messagePattern":"Dir is not accessible\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/promclient/promclient.go","lineNumber":172,"sourceCode":"\tf, err := os.Stat(filepath.Join(dir, \"wal\"))\n\tif err != nil {\n\t\treturn errors.Wrap(err, errMsg)\n\t}\n\n\tif !f.IsDir() {\n\t\treturn errors.New(errMsg)\n\t}\n\n\treturn nil\n}\n\n// IsDirAccessible returns no error if dir can be found.\nfunc IsDirAccessible(dir string) error {\n\tconst errMsg = \"Dir is not accessible.\"\n\n\tf, err := os.Stat(dir)\n\tif err != nil {\n\t\treturn errors.Wrap(err, errMsg)\n\t}\n\n\tif !f.IsDir() {\n\t\treturn errors.New(errMsg)\n\t}\n\n\treturn nil\n}\n\n// ExternalLabels returns sorted external labels from /api/v1/status/config Prometheus endpoint.\n// Note that configuration can be hot reloadable on Prometheus, so this config might change in runtime.\nfunc (c *Client) ExternalLabels(ctx context.Context, base *url.URL) (labels.Labels, error) {\n\tu := *base\n\tu.Path = path.Join(u.Path, \"/api/v1/status/config\")\n\n\tspan, ctx := tracing.StartSpan(ctx, \"/prom_config HTTP[client]\")\n\tdefer span.Finish()\n","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/promclient/promclient.go#L154-L190","documentation":"IsDirAccessible verifies a directory exists and is readable; when os.Stat fails (path missing, permission denied, or path is on an unreachable mount) the stat error is wrapped with 'Dir is not accessible.'.","triggerScenarios":"os.Stat(dir) returns an error for the directory passed to IsDirAccessible — nonexistent path or permission problem. Invoked by an anonymous caller (e.g. tooling validating a compactor/rule directory before use).","commonSituations":"Pointing Thanos tools at a directory that doesn't exist on the host; running the binary as a user without read permission on the data dir; directory only available after a mount that hasn't happened yet.","solutions":["Confirm the directory exists: ls -ld <dir>","Fix permissions: chown/chmod so the running user can stat/read it","Ensure the volume is mounted before the process starts","Correct the flag/config value that holds the wrong path"],"exampleFix":"// before\nthanos tools bucket verify --objstore.config-file=... --data-dir=/missing/dir\n// after\nmkdir -p /var/lib/thanos/verify\nthanos tools bucket verify --objstore.config-file=... --data-dir=/var/lib/thanos/verify","handlingStrategy":"validation","validationCode":"func dirExists(path string) error {\n    info, err := os.Stat(path)\n    if err != nil { return err }\n    if !info.IsDir() { return fmt.Errorf(\"%s is not a directory\", path) }\n    return nil\n}\n// call before using the dir\nif err := dirExists(dataDir); err != nil { return err }","typeGuard":null,"tryCatchPattern":"if err := promclient.IsDirAccessible(dataDir); err != nil {\n    log.Fatalf(\"data dir unusable: %v\", err)\n}","preventionTips":["Create directories with os.MkdirAll before pointing tools at them","Run services with a user that has read access to data directories","Use startup/init containers to guarantee mounts are ready"],"tags":["filesystem","directory","permissions"],"backgroundTag":"directory-not-found","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}