{"record":{"id":"973fd90a785a27f0","repo":"louislam/uptime-kuma","slug":"invalid-db-config-json-it-must-be-an-object","errorCode":null,"errorMessage":"Invalid db-config.json, it must be an object","messagePattern":"Invalid db-config\\.json, it must be an object","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"info","filePath":"server/database.js","lineNumber":212,"sourceCode":"        } catch (e) {\n            return \"\";\n        }\n    }\n\n    /**\n     * Read the database config\n     * @throws {Error} If the config is invalid\n     * @typedef {string|undefined} envString\n     * @returns {{type: \"sqlite\"} | {type:envString, hostname:envString, port:envString, database:envString, username:envString, password:envString, socketPath:envString}} Database config\n     */\n    static readDBConfig() {\n        let dbConfig;\n\n        let dbConfigString = fs.readFileSync(path.join(Database.dataDir, \"db-config.json\")).toString(\"utf-8\");\n        dbConfig = JSON.parse(dbConfigString);\n\n        if (typeof dbConfig !== \"object\") {\n            throw new Error(\"Invalid db-config.json, it must be an object\");\n        }\n\n        if (typeof dbConfig.type !== \"string\") {\n            throw new Error(\"Invalid db-config.json, type must be a string\");\n        }\n        return dbConfig;\n    }\n\n    /**\n     * @typedef {string|undefined} envString\n     * @param {{type: \"sqlite\"} | {type:envString, hostname:envString, port:envString, database:envString, username:envString, password:envString, socketPath:envString}} dbConfig the database configuration that should be written\n     * @returns {void}\n     */\n    static writeDBConfig(dbConfig) {\n        fs.writeFileSync(path.join(Database.dataDir, \"db-config.json\"), JSON.stringify(dbConfig, null, 4));\n    }\n\n    /**","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/database.js#L194-L230","documentation":"Thrown locally by autoGetTelegramChatID (Telegram.vue:198) when the Telegram bot getUpdates call returns successfully but res.data.result is empty (length < 1). With no update entries there is nothing to derive a chat ID from, so the code throws to tell the user the bot has not yet received any interaction. It is caught and shown as a toast, signalling a setup step is still missing.","triggerScenarios":"Clicking 'Auto Get' when res.data.result is an empty array. This occurs when the bot has never been messaged, when updates were already acknowledged by a prior getUpdates call carrying an offset, or when a webhook is currently registered for the bot (the Telegram Bot API returns 409 Conflict / no usable getUpdates payload while a webhook is active). Also possible if telegramServerUrl points at a local Bot API server that returns a different shape.","commonSituations":"User pasted a freshly created bot token but never pressed /start in Telegram. A webhook was set by another integration so polling yields nothing. A custom telegramServerUrl was configured (Telegram.vue:60) that is unreachable or returns an unexpected body. A token with stray whitespace produces an ok:false response, leaving result absent or empty.","solutions":["In Telegram, open a chat with the bot and send /start (or post once to the target channel with the bot added), then click 'Auto Get' again.","Open the telegramGetUpdatesURL link shown in the form in a browser and confirm the JSON has ok:true with a populated result array.","If a webhook is set elsewhere, remove it via the Telegram deleteWebhook endpoint, then retry getUpdates.","Leave telegramServerUrl at its default https://api.telegram.org unless you genuinely run a local Bot API server, and trim whitespace from the token."],"exampleFix":"// before\nif (res.data.result.length >= 1) {\n    // ...extract chat id...\n} else {\n    throw new Error(this.$t(\"chatIDNotFound\"));\n}\n\n// after: validate response shape first, separate the two failure modes\nif (!res.data || res.data.ok !== true || !Array.isArray(res.data.result)) {\n    throw new Error(this.$t(\"chatIDNotFound\"));\n}\nif (res.data.result.length === 0) {\n    throw new Error(this.$t(\"telegramNoUpdatesYet\"));\n}","handlingStrategy":"validation","validationCode":"// Validate the response envelope before checking length\nconst res = await axios.get(this.telegramGetUpdatesURL(\"withToken\"));\nif (!res.data || res.data.ok !== true) {\n    this.$root.toastError(this.$t(\"telegramTokenInvalid\"));\n    return;\n}\nif (!Array.isArray(res.data.result) || res.data.result.length === 0) {\n    this.$root.toastError(this.$t(\"telegramNoUpdatesYet\"));\n    return;\n}\n// safe to inspect updates here","typeGuard":"// Confirm the Telegram getUpdates payload shape\nfunction isTelegramUpdatesEnvelope(payload) {\n    return payload != null\n        && payload.ok === true\n        && Array.isArray(payload.result);\n}\n\nif (!isTelegramUpdatesEnvelope(res.data)) {\n    this.$root.toastError(this.$t(\"chatIDNotFound\"));\n    return;\n}","tryCatchPattern":"try {\n    const res = await axios.get(this.telegramGetUpdatesURL(\"withToken\"));\n    if (!isTelegramUpdatesEnvelope(res.data) || res.data.result.length === 0) {\n        throw new Error(this.$t(\"telegramNoUpdatesYet\"));\n    }\n    // ...extract chat id...\n} catch (error) {\n    const msg = error.response\n        ? `${error.message} (HTTP ${error.response.status})`\n        : error.message;\n    this.$root.toastError(msg);\n}","preventionTips":["Run /start against the bot in Telegram before invoking Auto Get.","Confirm the getUpdates link in the form returns ok:true with a non-empty result array in a browser first.","Remove any webhook set on the token before polling with Auto Get.","Keep telegramServerUrl at https://api.telegram.org unless you operate a local Bot API server, and trim whitespace from the token."],"tags":["telegram","bot-api","getupdates","vue","notification-provider","empty-response","user-facing"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}