owasp-amass/amass · error
AddCredentials: The Credentials argument is invalid
Error message
AddCredentials: The Credentials argument is invalid
What it means
AddCredentials on DataSourceConfig adds a *Credentials entry keyed by name. If the argument is nil or has an empty Name, the credentials cannot be keyed or used, so this error is returned without mutating state.
Source
Thrown at cmd/oam_i2y/ini.go:332
defer c.Unlock()
key := strings.TrimSpace(source)
if key == "" {
return nil
}
if c.datasrcConfigs == nil {
c.datasrcConfigs = make(map[string]*DataSourceConfig)
}
if _, found := c.datasrcConfigs[key]; !found {
c.datasrcConfigs[key] = &DataSourceConfig{Name: key}
}
return c.datasrcConfigs[key]
}
// AddCredentials adds the Credentials provided to the configuration.
func (dsc *DataSourceConfig) AddCredentials(cred *Credentials) error {
if cred == nil || cred.Name == "" {
return fmt.Errorf("AddCredentials: The Credentials argument is invalid")
}
if dsc.creds == nil {
dsc.creds = make(map[string]*Credentials)
}
dsc.creds[cred.Name] = cred
return nil
}
// AddDomain appends the domain name provided in the parameter to the list in the configuration.
func (c *Config) AddDomain(domain string) {
c.Lock()
defer c.Unlock()
// Check that the domain string is not empty
d := strings.TrimSpace(domain)
if d == "" {View on GitHub (pinned to 79299dce87)
Solutions
- Ensure the Credentials value is non-nil and Name is populated before calling AddCredentials.
- If loading credentials from a config file, check that the name/username key exists and is non-empty.
- Add a constructor (NewCredentials(name, pass)) that rejects empty names at creation time.
Example fix
// before
cred := &Credentials{Pass: "secret"}
dsc.AddCredentials(cred) // error: Name empty
// after
if cred.Name == "" {
cred.Name = cfg.GetString("datasource.username")
}
err := dsc.AddCredentials(cred) Defensive patterns
Strategy: validation
Validate before calling
if cred == nil || cred.Name == "" {
return errors.New("cannot add credentials: nil or missing Name")
}
return dsc.AddCredentials(cred) Type guard
func validCredentials(c *Credentials) bool {
return c != nil && c.Name != ""
} Try / catch
if err := dsc.AddCredentials(cred); err != nil {
if strings.Contains(err.Error(), "The Credentials argument is invalid") {
return fmt.Errorf("credential for %s missing name: %w", dsc.Name(), err)
}
} Prevention
- Construct credentials via a constructor that requires a non-empty name.
- Never pass zero-value Credentials structs.
- When loading from config, fail fast on empty username keys.
When it happens
Trigger: Calling dsc.AddCredentials(nil), or with &Credentials{Name: ""} (name never set, or set after construction and lost).
Common situations: Building credentials programmatically from config files where the username/name key is missing; zero-value Credentials structs passed in; refactored code that no longer populates Name before calling AddCredentials.
Related errors
- zero names provided in the Organization
- missing the organization name
- failed to provide a valid HTTP method
- AddCredentials: The accountName argument is invalid
- no log file specified
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/ff7ec1bc7f3419e3.
Report an issue: GitHub.