{"record":{"id":"4ab3e7e094931d64","repo":"thanos-io/thanos","slug":"unable-to-access-path-s","errorCode":null,"errorMessage":"unable to access path '%s'","messagePattern":"unable to access path '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/tools_bucket.go","lineNumber":1473,"sourceCode":"}\n\nfunc registerBucketUploadBlocks(app extkingpin.AppClause, objStoreConfig *extflag.PathOrContent) {\n\tcmd := app.Command(\"upload-blocks\", \"Upload blocks push blocks from the provided path to the object storage.\")\n\n\ttbc := &bucketUploadBlocksConfig{}\n\ttbc.registerBucketUploadBlocksFlag(cmd)\n\n\tcmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ <-chan struct{}, _ bool) error {\n\t\tif len(tbc.labels) == 0 {\n\t\t\treturn errors.New(\"no external labels configured, uniquely identifying external labels must be configured; see https://thanos.io/tip/thanos/storage.md#external-labels for details.\")\n\t\t}\n\n\t\tlset, err := parseFlagLabels(tbc.labels)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"unable to parse external labels\")\n\t\t}\n\t\tif err := promclient.IsDirAccessible(tbc.path); err != nil {\n\t\t\treturn errors.Wrapf(err, \"unable to access path '%s'\", tbc.path)\n\t\t}\n\n\t\tconfContentYaml, err := objStoreConfig.Content()\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"unable to parse objstore config\")\n\t\t}\n\n\t\tbkt, err := client.NewBucket(logger, confContentYaml, component.Upload.String(), nil)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"unable to create bucket\")\n\t\t}\n\n\t\tbkt = objstoretracing.WrapWithTraces(objstore.WrapWithMetrics(bkt, extprom.WrapRegistererWithPrefix(\"thanos_\", reg), bkt.Name()))\n\n\t\ttbcDir, err := os.OpenRoot(tbc.path)\n\t\tif err != nil {\n\t\t\trunutil.CloseWithLogOnErr(logger, bkt, \"bucket client\")\n\t\t\treturn errors.Wrap(err, \"unable to open tbc directory\")","sourceCodeStart":1455,"sourceCodeEnd":1491,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/tools_bucket.go#L1455-L1491","documentation":"This error is returned by the `thanos tools bucket upload` command when the directory specified by the --path flag cannot be accessed. The command calls promclient.IsDirAccessible on tbc.path before shipping local blocks to object storage; if that check fails, the underlying stat/open error is wrapped with the target path. It means the process either cannot see the directory or it is not a readable directory.","triggerScenarios":"Running `thanos tools bucket upload --path <dir>` where the path does not exist, is a regular file instead of a directory, the path contains a typo or relative-path mistake, or the OS user running thanos lacks read/execute permission on the directory or a parent.","commonSituations":"Typos in --path; running the tool inside a container where the data directory was not volume-mounted; running as a non-root user without permissions on the Prometheus data dir; pointing at a file (e.g. a block meta.json) instead of the directory; wrong working directory when using a relative path.","solutions":["Verify the path exists and is a directory: ls -ld <path>; correct the --path value if there is a typo","Check filesystem permissions (ls -ld each path component) and run the tool as a user with read/execute access, or fix ownership with chown/chmod","If running in Kubernetes/Docker, confirm the data directory is mounted into the container at the same path","Ensure you point at the block storage directory (TSDB dir), not a single block or meta.json file"],"exampleFix":"// before\nthanos tools bucket upload --path /var/thanos/typo-dir --objstore.bucket.config-file=bucket.yaml\n// after\nthanos tools bucket upload --path /var/thanos/store-dir --objstore.bucket.config-file=bucket.yaml","handlingStrategy":"validation","validationCode":"info, err := os.Stat(path)\nif err != nil {\n    return fmt.Errorf(\"path %q not accessible: %w\", path, err)\n}\nif !info.IsDir() {\n    return fmt.Errorf(\"%q is not a directory\", path)\n}\n// also ensure readability:\nif f, err := os.Open(path); err != nil {\n    return fmt.Errorf(\"directory %q not readable: %w\", path, err)\n} else {\n    f.Close()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass an absolute path to --path to avoid relative-path surprises","Pre-flight check with `ls -ld <path>` before running the tool, especially in containers","Ensure the data directory is mounted in containerized deployments","Run the tool as a user with read/execute permissions on the TSDB data directory"],"tags":["go","filesystem","cli","thanos"],"backgroundTag":"file-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"}