{"record":{"id":"5db53dbf5ac8668e","repo":"owasp-amass/amass","slug":"no-primary-database-specified-in-the-configuration","errorCode":null,"errorMessage":"no primary database specified in the configuration","messagePattern":"no primary database specified in the configuration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"engine/sessions/session.go","lineNumber":261,"sourceCode":"\t\t\tcase \"neo4+s\":\n\t\t\t\tfallthrough\n\t\t\tcase \"neo4j+sec\":\n\t\t\t\tfallthrough\n\t\t\tcase \"bolt\":\n\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 {","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/sessions/session.go#L243-L279","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (no database in config)\n{\n  \"databases\": []\n}\n// after\n{\n  \"databases\": [\n    { \"type\": \"sqlite\", \"path\": \"./assets.db\", \"primary\": true }\n  ]\n}","handlingStrategy":"validation","validationCode":"if len(cfg.Databases) == 0 || !hasPrimary(cfg.Databases) {\n    return errors.New(\"configuration must define a primary database before creating a session\")\n}\n\nfunc hasPrimary(dbs []Database) bool {\n    for _, d := range dbs {\n        if d.Primary {\n            return true\n        }\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["configuration","database","session"],"backgroundTag":"missing-required-config-field","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"}