{"record":{"id":"754ec8fc5b20118c","repo":"louislam/uptime-kuma","slug":"slug-accept-string-only","errorCode":null,"errorMessage":"Slug -Accept string only","messagePattern":"Slug -Accept string only","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/socket-handlers/status-page-socket-handler.js","lineNumber":450,"sourceCode":"        }\n    });\n\n    // Add a new status page\n    socket.on(\"addStatusPage\", async (title, slug, callback) => {\n        try {\n            checkLogin(socket);\n\n            title = title?.trim();\n            slug = slug?.trim();\n\n            // Check empty\n            if (!title || !slug) {\n                throw new Error(\"Please input all fields\");\n            }\n\n            // Make sure slug is string\n            if (typeof slug !== \"string\") {\n                throw new Error(\"Slug -Accept string only\");\n            }\n\n            // lower case only\n            slug = slug.toLowerCase();\n\n            checkSlug(slug);\n\n            let statusPage = R.dispense(\"status_page\");\n            statusPage.slug = slug;\n            statusPage.title = title;\n            statusPage.theme = \"auto\";\n            statusPage.icon = \"\";\n            statusPage.autoRefreshInterval = 300;\n            await R.store(statusPage);\n\n            callback({\n                ok: true,\n                msg: \"successAdded\",","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/socket-handlers/status-page-socket-handler.js#L432-L468","documentation":"Thrown by addStatusPage when slug's typeof is not 'string', after the empty-check passes. It hardens slug handling before toLowerCase()/checkSlug are applied, since trim() was called via slug?.trim() which would throw on non-string without optional chaining in some cases.","triggerScenarios":"Client emits addStatusPage with slug as a number, object, array, or boolean (e.g. slug: 123). title passes the empty check but slug fails typeof === 'string'.","commonSituations":"Client coercion bug (slug parsed as number from URL); JSON payload built dynamically with a numeric slug; type confusion between client and server contract.","solutions":["Pass slug as a string from the client (String(slug) before emitting if needed).","Validate typeof slug === 'string' client-side.","Align the client API contract to always send slug as string."],"exampleFix":"// before\nsocket.emit(\"addStatusPage\", \"Main\", 123, cb);\n// after\nsocket.emit(\"addStatusPage\", \"Main\", \"123\", cb);","handlingStrategy":"type-guard","validationCode":"if (typeof slug !== \"string\") slug = String(slug);\nsocket.emit(\"addStatusPage\", title, slug, cb);","typeGuard":"function isStringSlug(slug) {\n  return typeof slug === \"string\";\n}","tryCatchPattern":"try { await emitAsync(\"addStatusPage\", title, slug, cb); }\ncatch (e) { if (/Accept string only/.test(e.message)) retryWithStringSlug(); else throw e; }","preventionTips":["Always coerce slug to string on the client.","Validate typeof slug === 'string' before emit.","Keep the API contract typed (slug: string)."],"tags":["status-page","type-guard","slug","validation","socket-io"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}