{"record":{"id":"083c1c74b552f772","repo":"crowdsecurity/crowdsec","slug":"unknown-database-type-s","errorCode":null,"errorMessage":"unknown database type '%s'","messagePattern":"unknown database type '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/csconfig/database.go","lineNumber":235,"sourceCode":"\n\treturn connString, nil\n}\n\nfunc (d *DatabaseCfg) ConnectionDialect() (string, string, error) {\n\tswitch d.Type {\n\tcase \"sqlite\":\n\t\treturn \"sqlite3\", dialect.SQLite, nil\n\tcase \"mysql\":\n\t\treturn \"mysql\", dialect.MySQL, nil\n\tcase \"pgx\", \"postgresql\", \"postgres\":\n\t\tif d.Type != \"pgx\" {\n\t\t\tlog.Debugf(\"database type '%s' is deprecated, switching to 'pgx' instead\", d.Type)\n\t\t}\n\n\t\treturn \"pgx\", dialect.Postgres, nil\n\t}\n\n\treturn \"\", \"\", fmt.Errorf(\"unknown database type '%s'\", d.Type)\n}\n\nfunc (d *DatabaseCfg) isSocketConfig() bool {\n\treturn d.Host == \"\" && d.Port == 0 && d.DbPath != \"\"\n}\n","sourceCodeStart":217,"sourceCodeEnd":241,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csconfig/database.go#L217-L241","documentation":"ConnectionDialect maps the configured d.Type (mysql, sqlite, postgres, pgx, etc.) to a SQL dialect. If the type string does not match any known dialect it returns this error, which aborts NewClient before a database driver is ever opened. It is the strict validation guard against mistyped or unsupported database backends.","triggerScenarios":"database.type in the config yaml is set to anything other than mysql, sqlite, postgres, postgresql, or pgx — e.g. type: mysqlb, type: psql, or type: mariadb.","commonSituations":"Typos in database.yaml after editing, copy-pasted configs from other tools (e.g. 'psql'), or configs written for a hypothetical backend (mariadb) that crowdsec does not declare as a type.","solutions":["Set database.type to one of the supported values: mysql, sqlite, postgres, postgresql, or pgx.","For MariaDB, use type: mysql — the MySQL driver speaks the MariaDB wire protocol.","For PostgreSQL, prefer type: pgx (postgres/postgresql map to pgx anyway).","Check for trailing whitespace or wrong indentation in database.yaml that could corrupt the type value."],"exampleFix":"// before (database.yaml)\ndatabase:\n  type: psql\n// after\ndatabase:\n  type: pgx","handlingStrategy":"validation","validationCode":"var supported = []string{\"mysql\", \"sqlite\", \"postgres\", \"postgresql\", \"pgx\"}\nif !slices.Contains(supported, strings.TrimSpace(dbCfg.Type)) {\n    return fmt.Errorf(\"database.type %q not in %v\", dbCfg.Type, supported)\n}","typeGuard":null,"tryCatchPattern":"if _, err := dbCfg.ConnectionDialect(); err != nil {\n    log.Fatalf(\"invalid database config: %v\", err) // fail fast with clear message\n}","preventionTips":["Never hand-edit database.type; copy from the upstream example config.","Remember mariadb must be declared as mysql and postgres should be pgx.","Add a config lint step (yamllint + custom schema check) to deployment pipelines."],"tags":["database","config","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}