{"record":{"id":"84d16683a12abbc4","repo":"louislam/uptime-kuma","slug":"invalid-array","errorCode":null,"errorMessage":"Invalid array","messagePattern":"Invalid array","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/model/status_page.js","lineNumber":386,"sourceCode":"\n        let list = await R.findAll(\"status_page\", \" ORDER BY title \");\n\n        for (let item of list) {\n            result[item.id] = await item.toJSON();\n        }\n\n        io.to(socket.userID).emit(\"statusPageList\", result);\n        return list;\n    }\n\n    /**\n     * Update list of domain names\n     * @param {string[]} domainNameList List of status page domains\n     * @returns {Promise<void>}\n     */\n    async updateDomainNameList(domainNameList) {\n        if (!Array.isArray(domainNameList)) {\n            throw new Error(\"Invalid array\");\n        }\n\n        let trx = await R.begin();\n\n        await trx.exec(\"DELETE FROM status_page_cname WHERE status_page_id = ?\", [this.id]);\n\n        try {\n            for (let domain of domainNameList) {\n                if (typeof domain !== \"string\") {\n                    throw new Error(\"Invalid domain\");\n                }\n\n                if (domain.trim() === \"\") {\n                    continue;\n                }\n\n                // If the domain name is used in another status page, delete it\n                await trx.exec(\"DELETE FROM status_page_cname WHERE domain = ?\", [domain]);","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/model/status_page.js#L368-L404","documentation":"Thrown by StatusPage.updateDomainNameList(domainNameList) when the argument is not an array. The method deletes all existing CNAME mappings and re-inserts the provided list inside a transaction, so a non-array input would corrupt the iteration.","triggerScenarios":"Call updateDomainNameList with a string (\"example.com\"), an object ({domain: \"x\"}), null, or undefined. The guard fires before the transaction body iterates.","commonSituations":"API client sends a single domain string instead of a one-element array. JSON payload where the field was serialized as an object keyed by domain. Status-page import script that forgets to wrap the value in []","solutions":["Pass an array of strings, e.g. [\"status.example.com\"].","If you have a single domain, wrap it: Array.isArray(x) ? x : [x].","For an empty list, pass [] to clear all domains."],"exampleFix":"// before\nawait statusPage.updateDomainNameList(\"status.example.com\");\n// after\nawait statusPage.updateDomainNameList([\"status.example.com\"]);","handlingStrategy":"type-guard","validationCode":"function ensureDomainArray(list) {\n  if (!Array.isArray(list)) throw new Error(\"domainNameList must be an array\");\n  return list;\n}","typeGuard":"function isDomainNameList(list) {\n  return Array.isArray(list);\n}","tryCatchPattern":"try {\n  await statusPage.updateDomainNameList(list);\n} catch (e) {\n  if (/Invalid array/.test(e.message)) return badRequest(\"domains must be an array\");\n  throw e;\n}","preventionTips":["Wrap single values with [x] at the API boundary.","Type the field as string[] in your client schema."],"tags":["status-page","domain","validation","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}