owasp-amass/amass · error

failed to get absolute path: %v

Error message

failed to get absolute path: %v

What it means

loadResolversFromFile first converts the given path to an absolute path with filepath.Abs. Although filepath.Abs rarely fails (it can fail when os.Getwd fails, e.g. the working directory was deleted), any such error is wrapped as 'failed to get absolute path'.

Source

Thrown at config/resolvers.go:221

	}

	// Deduplicate the list of resolvers and assign to c.Resolvers.
	resolverIPs := stringset.Deduplicate(resolversList)

	if len(resolverIPs) == 0 {
		return errors.New("no valid resolvers were found")
	}

	c.Resolvers = resolverIPs

	return nil
}

func (c *Config) loadResolversFromFile(path string) ([]string, error) {
	absPath, err := filepath.Abs(path)
	if err != nil {
		return nil, fmt.Errorf("failed to get absolute path: %v", err)
	}

	data, err := os.ReadFile(absPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open resolvers file: %w", err)
	}

	// Split the file data by newlines to get the IP addresses.
	lines := strings.Split(string(data), "\n")

	var resolvers []string
	for _, line := range lines {
		line = strings.TrimSpace(line)
		// Skip empty lines.
		if line == "" {
			continue
		}

View on GitHub (pinned to 79299dce87)

Solutions

  1. Run the tool from a valid existing working directory (cd / before invoking).
  2. Pass an absolute path for the resolver file so filepath.Abs does not need the working directory.
  3. Restart the process from a valid directory if the workdir was deleted underneath it.

Example fix

// before
$ cd /tmp/scratch && rm -rf /tmp/scratch & amass ...
// after
$ cd ~ && amass ...  # resolver file given as absolute path
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Getwd(); err != nil {
    return errors.New("current working directory is invalid; cd to a real directory")
}

Try / catch

resolvers, err := loadResolversFromFile(path)
if err != nil {
    var pe *fs.PathError
    if errors.As(err, &pe) {
        return nil, fmt.Errorf("resolver file %s: %w", pe.Path, pe)
    }
    return nil, err
}

Prevention

When it happens

Trigger: Calling loadResolversFromFile (directly in tests via TestLoadResolversFromFile, or via loadResolverSettings) while the process's current working directory is invalid/deleted, making filepath.Abs unable to resolve a relative path.

Common situations: Running the tool from a directory that was removed or renamed while the process lives; exotic environments where os.Getwd fails; passing relative paths from a container whose workdir vanished.

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/7d29fd2f37f40049. Report an issue: GitHub.