owasp-amass/amass · critical
no primary database specified in the configuration
Error message
no primary database specified in the configuration
What it means
This error is returned by selectDBMS in the engine session setup when, after evaluating all configured databases, no primary database was selected. The session tracks its chosen database via s.dbtype and s.dsn; if either is empty, no usable connection string could be built. The library throws it because it cannot initialize an asset store (assetdb.New) without a database type and DSN.
Source
Thrown at engine/sessions/session.go:261
case "neo4+s":
fallthrough
case "neo4j+sec":
fallthrough
case "bolt":
fallthrough
case "bolt+s":
fallthrough
case "bolt+sec":
s.dsn = db.URL
s.dbtype = neo4j.Neo4j
}
// Break the loop once the primary database is found.
break
}
}
// Check if a valid database connection string was generated.
if s.dsn == "" || s.dbtype == "" {
return errors.New("no primary database specified in the configuration")
}
// Initialize the database store
store, err := assetdb.New(s.dbtype, s.dsn)
if err != nil {
return errors.New("failed to initialize database store: " + err.Error())
}
s.db = store
return nil
}
func (s *Session) createTemporaryDir() (string, error) {
outdir := config.OutputDirectory()
if outdir == "" {
return "", errors.New("failed to obtain the output directory")
}
dir, err := os.MkdirTemp(outdir, "session-"+s.ID().String())
if err != nil {View on GitHub (pinned to 79299dce87)
Solutions
- Add or restore a database entry flagged as primary in the session configuration (e.g. sqlite/postgres) so selectDBMS assigns s.dbtype and s.dsn
- Verify the config file actually loaded — check for wrong --config path or empty config struct before session creation
- Confirm the primary flag key spelling matches what the loader expects (e.g. 'primary: true')
- Log the parsed database configuration before setupDB to confirm entries are visible to the session
Example fix
// before (no database in config)
{
"databases": []
}
// after
{
"databases": [
{ "type": "sqlite", "path": "./assets.db", "primary": true }
]
} Defensive patterns
Strategy: validation
Validate before calling
if len(cfg.Databases) == 0 || !hasPrimary(cfg.Databases) {
return errors.New("configuration must define a primary database before creating a session")
}
func hasPrimary(dbs []Database) bool {
for _, d := range dbs {
if d.Primary {
return true
}
}
return false
} Prevention
- Always define exactly one primary database entry in the session config
- Validate the config schema at startup, before any session is created
- Add a smoke test that builds a session from the shipped default config
- Keep the primary flag key consistent with the loader's expected field name
When it happens
Trigger: Calling CreateSession/setupDB when the configuration contains no database entries at all, or every entry lacks the 'primary' flag so the loop never assigns s.dbtype/s.dsn.
Common situations: Fresh installs where the config file was not fully filled in; users commenting out or deleting the primary database block; config files with only read-replica or secondary database entries; typos in the primary flag key so it is never recognized.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- failed to initialize database store:
- failed to obtain the output directory
- environment variable %s is not set
- failed to create the OAM Service asset
- failed to create the Organization asset
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/5db53dbf5ac8668e.
Report an issue: GitHub.