{"record":{"id":"657e7755d2da47de","repo":"louislam/uptime-kuma","slug":"unknown-database-type-dbconfig-type","errorCode":null,"errorMessage":"Unknown Database type: ${dbConfig.type}","messagePattern":"Unknown Database type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/database.js","lineNumber":409,"sourceCode":"            config = {\n                client: \"mysql2\",\n                connection: {\n                    socketPath: embeddedMariaDB.socketPath,\n                    user: embeddedMariaDB.username,\n                    database: \"kuma\",\n                    timezone: \"Z\",\n                    typeCast: function (field, next) {\n                        if (field.type === \"DATETIME\") {\n                            // Do not perform timezone conversion\n                            return field.string();\n                        }\n                        return next();\n                    },\n                },\n                pool: mariadbPoolConfig,\n            };\n        } else {\n            throw new Error(\"Unknown Database type: \" + dbConfig.type);\n        }\n\n        // Set to utf8mb4 for MariaDB\n        if (dbConfig.type.endsWith(\"mariadb\")) {\n            config.pool = {\n                afterCreate(conn, done) {\n                    conn.query(\"SET CHARACTER SET utf8mb4;\", (err) => done(err, conn));\n                },\n            };\n        }\n\n        const knexInstance = knex(config);\n\n        R.setup(knexInstance);\n\n        if (process.env.SQL_LOG === \"1\") {\n            R.debug(true);\n        }","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/database.js#L391-L427","documentation":"At the bottom of the knex config switch in Database.connect(), after handling 'sqlite', 'mariadb'/'mysql' and 'embedded-mariadb', any other dbConfig.type value falls through to this throw. It is a literal fallthrough default — the supported set is hardcoded in this if/else chain (see database.js:387-409). The message echoes the offending type so the operator can see exactly what was read.","triggerScenarios":"db-config.json `type` is a typo (e.g. \"sqlite3\", \"postgres\", \"mysql2\", \"mariadb \" with trailing space, \"SQLITE\" in uppercase); a future/incompatible dbConfig from a newer version; manual edit to an unsupported backend like postgres.","commonSituations":"Operators switching databases who type an unrecognised engine name; case sensitivity mistakes; configs ported from another tool that uses different driver names.","solutions":["Set type to one of the supported values: \"sqlite\", \"mariadb\", \"embedded-mariadb\" (mysql is accepted via the mariadb branch).","Check for trailing whitespace or wrong case in db-config.json — the match is exact and lowercase.","If you intended PostgreSQL, know it is not supported; choose sqlite or mariadb.","After editing, restart Uptime Kuma so readDBConfig() re-reads the file."],"exampleFix":"// before — data/db-config.json\n{ \"type\": \"postgres\" }\n\n// after — pick a supported backend\n{ \"type\": \"mariadb\", \"hostname\": \"127.0.0.1\", \"port\": 3306, \"database\": \"kuma\", \"username\": \"kuma\", \"password\": \"secret\" }","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set([\"sqlite\", \"mariadb\", \"embedded-mariadb\"]);\nfunction assertSupportedType(cfg) {\n    if (!SUPPORTED.has(cfg.type)) {\n        throw new Error(`Unsupported db type '${cfg.type}'. Supported: ${[...SUPPORTED].join(\", \")}`);\n    }\n}","typeGuard":"function isSupportedDbType(cfg) {\n    return cfg !== null && [\"sqlite\", \"mariadb\", \"embedded-mariadb\"].includes(cfg.type);\n}","tryCatchPattern":"try {\n    await Database.connect();\n} catch (e) {\n    if (/Unknown Database type/.test(e.message)) {\n        // fix db-config.json type, then restart\n    }\n    throw e;\n}","preventionTips":["Keep dbConfig.type lowercase and exactly matching one of the supported values.","Document the supported set in your deployment runbook.","Add a startup self-test that fails fast with a clearer message if the type is unknown."],"tags":["database","config","startup"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}