{"record":{"id":"39030567bbdba4ba","repo":"owasp-amass/amass","slug":"expected-database-to-be-a-string-got-t","errorCode":null,"errorMessage":"expected 'database' to be a string, got %T","messagePattern":"expected 'database' to be a string, got %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/graphdb.go","lineNumber":49,"sourceCode":"\tassetPort   = \"AMASS_DB_PORT\"\n\tassetDBName = \"AMASS_DB_NAME\"\n)\n\nfunc (c *Config) loadDatabaseSettings(cfg *Config) error {\n\tif c.Options == nil {\n\t\treturn fmt.Errorf(\"config options are not initialized\")\n\t}\n\n\tdbURIInterface, ok := c.Options[\"database\"]\n\tif !ok {\n\t\tif err := c.LoadDatabaseEnvSettings(); err != nil {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tdbURI, ok := dbURIInterface.(string)\n\tif !ok {\n\t\treturn fmt.Errorf(\"expected 'database' to be a string, got %T\", dbURIInterface)\n\t}\n\n\tif _, err := url.Parse(dbURI); err == nil {\n\t\tif err := c.loadDatabase(dbURI); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\n// LoadDatabaseEnvSettings initializes the DB structure with the Environment variables.\nfunc (c *Config) LoadDatabaseEnvSettings() error {\n\tdbURI := \"\"\n\tdb := &Database{\n\t\tPrimary: true,\n\t\tSystem:  \"postgres\",\n\t}\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/graphdb.go#L31-L67","documentation":"loadDatabaseSettings found a value under the 'database' option key whose Go type is not string (the %T verb shows the actual type, e.g. map or float from YAML). The subsequent dbURIInterface.(string) assertion fails, so the database URI cannot be parsed or passed to loadDatabase.","triggerScenarios":"Thrown at config/graphdb.go:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Write the 'database' setting as a URI string, e.g. \"postgres://user:pass@host:5432/dbname\"","If YAML anchors or nesting produced a map, flatten it to a single URI string","Validate the config schema up front so non-string 'database' values are rejected with a location hint"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}