{"record":{"id":"8e1d8c660e3a1419","repo":"owasp-amass/amass","slug":"failed-to-get-absolute-path-v-8e1d8c","errorCode":null,"errorMessage":"failed to get absolute path: %v","messagePattern":"failed to get absolute path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/wordlist.go","lineNumber":87,"sourceCode":"func ExpandMaskWordlist(wordlist []string) ([]string, error) {\n\tvar newWordlist []string\n\n\tfor _, word := range wordlist {\n\t\tif words, err := ExpandMask(word); err == nil {\n\t\t\tnewWordlist = append(newWordlist, words...)\n\t\t}\n\t}\n\n\treturn newWordlist, nil\n}\n\n// GetListFromFile reads a wordlist text or gzip file and returns the slice of words.\nfunc GetListFromFile(path string) ([]string, error) {\n\tvar reader io.Reader\n\n\tabsPath, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get absolute path: %v\", err)\n\t}\n\n\tfile, err := os.Open(absPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error opening the file %s: %v\", absPath, err)\n\t}\n\tdefer func() { _ = file.Close() }()\n\treader = file\n\n\tif finfo, err := file.Stat(); err == nil && finfo.Size() == 0 {\n\t\treturn nil, errors.New(\"the file is empty\")\n\t}\n\n\tif gz, err := getGzipReader(file, absPath); err == nil {\n\t\tdefer func() { _ = gz.Close() }()\n\t\treader = gz\n\t}\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/wordlist.go#L69-L105","documentation":"GetListFromFile first resolves the given wordlist path to an absolute path with filepath.Abs; this error wraps any failure of that resolution. filepath.Abs fails almost exclusively when os.Getwd fails (e.g. the working directory was deleted), since it merely joins the working directory to a relative path.","triggerScenarios":"Calling GetListFromFile (via loadBruteForceSettings, loadAlterationSettings, or CLIWorkflow) while the process's current working directory no longer exists.","commonSituations":"Running the tool from a directory that was removed or renamed; running in a container where the workdir was deleted after start.","solutions":["Pass an absolute path to the wordlist so filepath.Abs is a no-op","Restore/re-enter a valid working directory before running","Check the wrapped error (%v) to confirm Getwd failed"],"exampleFix":"// before\nwords, err := GetListFromFile(\"wordlists/common.txt\")\n// after\nwords, err := GetListFromFile(\"/usr/share/wordlists/common.txt\")","handlingStrategy":"validation","validationCode":"func wdExists() error { _, err := os.Getwd(); return err }\n// call wdExists() before GetListFromFile with a relative path","typeGuard":null,"tryCatchPattern":"words, err := GetListFromFile(p)\nif err != nil {\n  if strings.HasPrefix(err.Error(), \"failed to get absolute path\") {\n    // chdir to a valid directory or use absolute paths\n  }\n  return err\n}","preventionTips":["Always pass absolute wordlist paths","Never delete the directory a process is running from","Add a startup check that os.Getwd succeeds"],"tags":["wordlist","filepath","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}