owasp-amass/amass · error

datasources option is not a string

Error message

datasources option is not a string

What it means

loadDataSourceSettings reads the 'datasources' option from the config options map, which must be a string path to a data-sources file. If the value is present but not a string (number, bool, list, map), the load fails with 'datasources option is not a string'. This is an early type check before the path is resolved and loaded.

Source

Thrown at config/datasrcs.go:97

			for _, creds := range src.Creds {
				return creds // Return the first set of credentials found
			}
		}
	}
	return nil
}

func (c *Config) loadDataSourceSettings(cfg *Config) error {
	// Retrieve the datasources file path from the options
	pathInterface, ok := c.Options["datasources"]
	if !ok {
		// "datasources" not found in options, so nothing to do here.
		return nil
	}

	path, ok := pathInterface.(string)
	if !ok {
		return fmt.Errorf("datasources option is not a string")
	}
	// Construct the absolute path by joining the current working directory and the relative path
	absPath, err := c.AbsPathFromConfigDir(path)
	if err != nil {
		return fmt.Errorf("failed to get absolute path: %v", err)
	}
	// Load the datasources YAML file
	data, err := os.ReadFile(absPath)
	if err != nil {
		return fmt.Errorf("error reading datasources file: %v", err)
	}
	// Unmarshal the YAML data into a DataSourceConfig
	var dsConfig DataSourceConfig
	err = yaml.Unmarshal(data, &dsConfig)
	if err != nil {
		return fmt.Errorf("error unmarshalling datasources YAML: %v", err)
	}

View on GitHub (pinned to 79299dce87)

Solutions

  1. Quote the value so YAML parses it as a string: datasources: "datasources.yaml".
  2. Confirm the option expects a path to a datasources file, not an inline structure.
  3. Validate the config with a YAML parser and inspect the datasources value's type.
  4. If the value is generated programmatically, stringify it before writing the config.

Example fix

// before (config.yaml)
datasources: 2024
// after
datasources: "2024.yaml"
Defensive patterns

Strategy: validation

Validate before calling

raw, _ := os.ReadFile(cfgPath)
var doc map[string]any
_ = yaml.Unmarshal(raw, &doc)
if v, ok := doc["datasources"]; ok {
    if _, ok := v.(string); !ok {
        return fmt.Errorf("datasources must be a string path, got %T", v)
    }
}

Type guard

func isString(v any) bool {
    _, ok := v.(string)
    return ok
}

Try / catch

if err := cfg.LoadSettings(path); err != nil {
    if strings.Contains(err.Error(), "datasources option is not a string") {
        // quote the value or correct the type in the config
    }
    return err
}

Prevention

When it happens

Trigger: A config with a non-string 'datasources' value, e.g. datasources: 123, datasources: true, or datasources: [a.yaml]. Triggered during LoadSettings when the key exists in options and the interface type assertion to string fails.

Common situations: Hand-edited YAML where an unquoted filename looks numeric (datasources: 2024.yaml becomes an int); tooling that generated the config with the wrong type; misunderstanding that datasources takes a file path, not an inline list.

Related errors


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