owasp-amass/amass · error

error when splitting the key: %w

Error message

error when splitting the key: %w

What it means

loadTransformSettings reads each key of the config's 'transformations' map and asks Transformation.Split to parse it as 'from->to'. When Split fails, this error wraps the underlying reason (e.g. invalid key delimiter). It means a transformation key in your config does not follow the required 'From->To' format.

Source

Thrown at config/transform.go:52

// loadTransformSettings processes the Transformations map from the configuration,
// assigning structured data to each Transformation based on its key.
// Each key is parsed into 'From' and 'To' segments, representing the origin and target
// of the transformation, respectively, which are then stored in the corresponding Transformation struct.
func (c *Config) loadTransformSettings(cfg *Config) error {
	// Retrieve the global options from the Options, if it's set.
	if err := c.loadGlobalTransformSettings(); err != nil {
		return err
	}
	// Iterate through each transformation rule defined in the configuration.
	for key, transformation := range c.Transformations {
		// Initialize transformation if nil
		if transformation == nil {
			transformation = &Transformation{}      // default struct
			c.Transformations[key] = transformation // assign it back to the map
		}
		// Spit the key into 'From' and 'To' components.
		if err := transformation.Split(key); err != nil {
			return fmt.Errorf("error when splitting the key: %w", err)
		}
		// Apply the global confidence if no specific confidence is set for this transformation.
		if transformation.Confidence == 0 {
			transformation.Confidence = c.DefaultTransformations.Confidence
		}
		if transformation.TTL == 0 {
			transformation.TTL = c.DefaultTransformations.TTL
		}

		err := transformation.Validate(c)
		if err != nil {
			return err
		}
	}
	// If the loop completes with no conflicts, the function returns nil, indicating success.
	return nil
}

View on GitHub (pinned to 79299dce87)

Solutions

  1. Rewrite the transformation key using the '->' delimiter exactly once: 'from->to'
  2. Split multi-hop transformations into separate single-hop entries
  3. Validate key format with strings.Count(key, "-") == 1 before loading

Example fix

// before
transformations:
  subdomain:ip: {}
// after
transformations:
  subdomain->ip: {}
Defensive patterns

Strategy: try-catch

Validate before calling

for key := range transformationsRaw {
	if strings.Count(key, "->") != 1 {
		return fmt.Errorf("transformation key %q must be 'from->to'", key)
	}
}

Try / catch

if err := cfg.LoadSettings(path); err != nil {
	if strings.Contains(err.Error(), "error when splitting the key") {
		return fmt.Errorf("config has malformed transformation keys: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Config YAML containing a transformations entry keyed by anything other than exactly one '->' separated pair, e.g. 'a>b' or 'a->b->c', loaded via prepareConfig/Config loading.

Common situations: Hand-written transformation sections in amass config YAML, using '=>' or ':' instead of '->', or chaining multiple hops in a single key.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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