{"record":{"id":"f631906de514c75c","repo":"thanos-io/thanos","slug":"read-dir","errorCode":null,"errorMessage":"read dir","messagePattern":"read dir","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runutil/runutil.go","lineNumber":188,"sourceCode":"\n\t// Prepend the io.Copy error.\n\tmerr := errutil.MultiError{}\n\tmerr.Add(copyErr)\n\tmerr.Add(*err)\n\n\t*err = merr.Err()\n}\n\n// DeleteAll deletes all files and directories inside the given\n// dir except for the ignoreDirs directories.\n// NOTE: DeleteAll is not idempotent.\nfunc DeleteAll(dir string, ignoreDirs ...string) error {\n\tentries, err := os.ReadDir(dir)\n\tif os.IsNotExist(err) {\n\t\treturn nil\n\t}\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"read dir\")\n\t}\n\tvar groupErrs errutil.MultiError\n\n\tvar matchingIgnores []string\n\tfor _, d := range entries {\n\t\tif !d.IsDir() {\n\t\t\tif err := os.RemoveAll(filepath.Join(dir, d.Name())); err != nil {\n\t\t\t\tgroupErrs.Add(err)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// ignoreDirs might be multi-directory paths.\n\t\tmatchingIgnores = matchingIgnores[:0]\n\t\tignore := false\n\t\tfor _, ignoreDir := range ignoreDirs {\n\t\t\tid := strings.Split(ignoreDir, \"/\")\n\t\t\tif id[0] == d.Name() {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/runutil/runutil.go#L170-L206","documentation":"Raised in runutil.DeleteAll when os.ReadDir on the target directory fails with an error other than not-exist (which is tolerated and returns nil). Typical causes are permission denied on dir or dir being a non-directory path; deletion aborts before removing anything.","triggerScenarios":"Thrown at pkg/runutil/runutil.go:188 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check permissions on the directory being deleted","Ensure the path is a directory, not a file or mount point","Handle the not-exist case — DeleteAll already tolerates it by design"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}