owasp-amass/amass · error

failed to get absolute path: %v

Error message

failed to get absolute path: %v

What it means

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.

Source

Thrown at config/wordlist.go:87

func ExpandMaskWordlist(wordlist []string) ([]string, error) {
	var newWordlist []string

	for _, word := range wordlist {
		if words, err := ExpandMask(word); err == nil {
			newWordlist = append(newWordlist, words...)
		}
	}

	return newWordlist, nil
}

// GetListFromFile reads a wordlist text or gzip file and returns the slice of words.
func GetListFromFile(path string) ([]string, error) {
	var reader io.Reader

	absPath, err := filepath.Abs(path)
	if err != nil {
		return nil, fmt.Errorf("failed to get absolute path: %v", err)
	}

	file, err := os.Open(absPath)
	if err != nil {
		return nil, fmt.Errorf("error opening the file %s: %v", absPath, err)
	}
	defer func() { _ = file.Close() }()
	reader = file

	if finfo, err := file.Stat(); err == nil && finfo.Size() == 0 {
		return nil, errors.New("the file is empty")
	}

	if gz, err := getGzipReader(file, absPath); err == nil {
		defer func() { _ = gz.Close() }()
		reader = gz
	}

View on GitHub (pinned to 79299dce87)

Solutions

  1. Pass an absolute path to the wordlist so filepath.Abs is a no-op
  2. Restore/re-enter a valid working directory before running
  3. Check the wrapped error (%v) to confirm Getwd failed

Example fix

// before
words, err := GetListFromFile("wordlists/common.txt")
// after
words, err := GetListFromFile("/usr/share/wordlists/common.txt")
Defensive patterns

Strategy: validation

Validate before calling

func wdExists() error { _, err := os.Getwd(); return err }
// call wdExists() before GetListFromFile with a relative path

Try / catch

words, err := GetListFromFile(p)
if err != nil {
  if strings.HasPrefix(err.Error(), "failed to get absolute path") {
    // chdir to a valid directory or use absolute paths
  }
  return err
}

Prevention

When it happens

Trigger: Calling GetListFromFile (via loadBruteForceSettings, loadAlterationSettings, or CLIWorkflow) while the process's current working directory no longer exists.

Common situations: Running the tool from a directory that was removed or renamed; running in a container where the workdir was deleted after start.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/8e1d8c660e3a1419. Report an issue: GitHub.