owasp-amass/amass · critical
failed to initialize database store:
Error message
failed to initialize database store:
What it means
This error wraps the failure of assetdb.New(dbtype, dsn), which constructs the database-backed asset store for a session. The selected dbtype/dsn were non-empty, but the store driver rejected them (unknown driver, bad DSN, unreachable server, etc.). It surfaces during setupDB/selectDBMS when the session tries to open its primary database.
Source
Thrown at engine/sessions/session.go:266
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 {
return "", errors.New("failed to create the temp dir")
}
return dir, nil
}View on GitHub (pinned to 79299dce87)
Solutions
- Check the wrapped err.Error() message for the driver-specific cause (unknown driver vs connection failure)
- Verify the dbtype string matches a supported assetdb driver exactly
- Test the DSN with a standalone client (psql, mysql, sqlite3) to confirm host, port, credentials, and path
- Ensure the sqlite file path is writable or the network database is reachable from the host
- Confirm any required database driver dependency is installed/imported
Example fix
// before
{ "type": "sqllite", "dsn": "file:///root/assets.db", "primary": true }
// after
{ "type": "sqlite", "dsn": "./assets.db", "primary": true } Defensive patterns
Strategy: try-catch
Validate before calling
if dbtype != "sqlite" && dbtype != "postgres" && dbtype != "mysql" {
return errors.New("unsupported database type: " + dbtype)
}
if dsn == "" {
return errors.New("empty DSN for database type " + dbtype)
} Try / catch
if err := session.CreateSession(cfg); err != nil {
var storeErr string
if strings.HasPrefix(err.Error(), "failed to initialize database store:") {
storeErr = strings.TrimPrefix(err.Error(), "failed to initialize database store: ")
log.Fatalf("asset store init failed, driver said: %s", storeErr)
}
return err
} Prevention
- Test the DSN with a standalone client before wiring it into config
- Pin and verify the dbtype against the list of supported assetdb drivers
- Run a startup health-check that opens and closes the database connection
- Keep driver dependencies and database server versions compatible
When it happens
Trigger: assetdb.New returns an error: unrecognized dbtype string, malformed DSN for the chosen driver, or the database server is unreachable/credentials rejected at open time.
Common situations: Typo in the configured database type (e.g. 'sqllite'); wrong host/port or password in the DSN; database server not running; missing driver dependency; file path for a sqlite DSN in a non-writable directory.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- no primary database specified in the configuration
- environment variable %s is not set
- failed to create the session manager
- failed to create the API server
- failed to create the RDAP disk cache
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/ccd108a5369d7a9d.
Report an issue: GitHub.