{"record":{"id":"ccd108a5369d7a9d","repo":"owasp-amass/amass","slug":"failed-to-initialize-database-store","errorCode":null,"errorMessage":"failed to initialize database store: ","messagePattern":"failed to initialize database store: ","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"engine/sessions/session.go","lineNumber":266,"sourceCode":"\t\t\t\tfallthrough\n\t\t\tcase \"bolt+s\":\n\t\t\t\tfallthrough\n\t\t\tcase \"bolt+sec\":\n\t\t\t\ts.dsn = db.URL\n\t\t\t\ts.dbtype = neo4j.Neo4j\n\t\t\t}\n\t\t\t// Break the loop once the primary database is found.\n\t\t\tbreak\n\t\t}\n\t}\n\t// Check if a valid database connection string was generated.\n\tif s.dsn == \"\" || s.dbtype == \"\" {\n\t\treturn errors.New(\"no primary database specified in the configuration\")\n\t}\n\t// Initialize the database store\n\tstore, err := assetdb.New(s.dbtype, s.dsn)\n\tif err != nil {\n\t\treturn errors.New(\"failed to initialize database store: \" + err.Error())\n\t}\n\ts.db = store\n\treturn nil\n}\n\nfunc (s *Session) createTemporaryDir() (string, error) {\n\toutdir := config.OutputDirectory()\n\tif outdir == \"\" {\n\t\treturn \"\", errors.New(\"failed to obtain the output directory\")\n\t}\n\n\tdir, err := os.MkdirTemp(outdir, \"session-\"+s.ID().String())\n\tif err != nil {\n\t\treturn \"\", errors.New(\"failed to create the temp dir\")\n\t}\n\n\treturn dir, nil\n}","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/sessions/session.go#L248-L284","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n{ \"type\": \"sqllite\", \"dsn\": \"file:///root/assets.db\", \"primary\": true }\n// after\n{ \"type\": \"sqlite\", \"dsn\": \"./assets.db\", \"primary\": true }","handlingStrategy":"try-catch","validationCode":"if dbtype != \"sqlite\" && dbtype != \"postgres\" && dbtype != \"mysql\" {\n    return errors.New(\"unsupported database type: \" + dbtype)\n}\nif dsn == \"\" {\n    return errors.New(\"empty DSN for database type \" + dbtype)\n}","typeGuard":null,"tryCatchPattern":"if err := session.CreateSession(cfg); err != nil {\n    var storeErr string\n    if strings.HasPrefix(err.Error(), \"failed to initialize database store:\") {\n        storeErr = strings.TrimPrefix(err.Error(), \"failed to initialize database store: \")\n        log.Fatalf(\"asset store init failed, driver said: %s\", storeErr)\n    }\n    return err\n}","preventionTips":["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"],"tags":["database","configuration","initialization"],"backgroundTag":"database-query-failed","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}