owasp-amass/amass · error

failed to get absolute path for resolver file

Error message

failed to get absolute path for resolver file: %w

What it means

When a resolver entry is not an IP, loadResolverSettings treats it as a file path of resolvers and resolves it to an absolute path via c.AbsPathFromConfigDir. If that helper errors, the failure is wrapped in this error.

Solutions

  1. Use an absolute path for the resolver file in the config (e.g. /etc/amass/resolvers.txt).
  2. Verify the config directory is correctly set/discoverable and that AbsPathFromConfigDir's wrapped cause (available via errors.Unwrap) is addressed.
  3. Ensure the referenced file exists relative to the config directory, or create it.

Example fix

// before
resolvers:
  - "my-resolvers.txt"
// after
resolvers:
  - "/home/user/.config/amass/my-resolvers.txt"
Defensive patterns

Strategy: validation

Validate before calling

if !filepath.IsAbs(rStr) {
    if _, err := os.Stat(filepath.Join(configDir, rStr)); err != nil {
        return fmt.Errorf("resolver file %s not found in config dir", rStr)
    }
}

Try / catch

if err := loadResolverSettings(); err != nil {
    if strings.Contains(err.Error(), "absolute path for resolver file") {
        return fmt.Errorf("use absolute path for resolver file: %w", err)
    }
}

Prevention

When it happens

Trigger: A resolver entry like 'resolvers.txt' whose relative path cannot be resolved against the config directory — e.g. the config dir is unknown/empty or path computation fails inside AbsPathFromConfigDir.

Common situations: Running with a custom config location the tool cannot anchor; referring to a resolver file by name that does not exist relative to the config dir; permissions preventing directory traversal.

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

Appendix: source

Thrown at config/resolvers.go:194

	var resolversList []string
	for _, r := range resolvers {
		// Type assert the resolver to string
		rStr, ok := r.(string)
		if !ok {
			return fmt.Errorf("resolver entry %v is not a string", r)
		}

		// Check if rStr is an IP address.
		ip := net.ParseIP(rStr)
		if ip != nil {
			resolversList = append(resolversList, rStr)
			continue
		}

		// rStr is not an IP address, so we assume it is a file path.
		absPath, err := c.AbsPathFromConfigDir(rStr)
		if err != nil {
			return fmt.Errorf("failed to get absolute path for resolver file: %w", err)
		}

		fileResolvers, err := c.loadResolversFromFile(absPath)
		if err != nil {
			return fmt.Errorf("failed to load resolvers from file: %w", err)
		}

		resolversList = append(resolversList, fileResolvers...)

	}

	// 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")
	}

View on GitHub (pinned to 79299dce87)