{"record":{"id":"522d673faa6564d0","repo":"louislam/uptime-kuma","slug":"slug-cannot-be-empty","errorCode":null,"errorMessage":"Slug cannot be empty","messagePattern":"Slug cannot be empty","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/socket-handlers/status-page-socket-handler.js","lineNumber":541,"sourceCode":"    });\n};\n\n/**\n * Check slug a-z, 0-9, - only\n * Regex from: https://stackoverflow.com/questions/22454258/js-regex-string-validation-for-slug\n * @param {string} slug Slug to test\n * @returns {void}\n * @throws Slug is not valid\n */\nfunction checkSlug(slug) {\n    if (typeof slug !== \"string\") {\n        throw new Error(\"Slug must be string\");\n    }\n\n    slug = slug.trim();\n\n    if (!slug) {\n        throw new Error(\"Slug cannot be empty\");\n    }\n\n    if (!slug.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/)) {\n        throw new Error(\"Invalid Slug\");\n    }\n}\n","sourceCodeStart":523,"sourceCodeEnd":548,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/socket-handlers/status-page-socket-handler.js#L523-L548","documentation":"Thrown by checkSlug() after `slug = slug.trim()` when the trimmed result is falsy (empty string). It is the second validation gate, ensuring the slug is not blank before the regex check. Required because an empty slug would create an unreachable status page route and would conflict with reserved paths.","triggerScenarios":"saveStatusPage emitted with `config.slug` equal to \"\", \"   \" (whitespace only), or a value that trims to empty. Also reachable from createStatusPage (line 456) if the earlier `!slug` check at line 444 is bypassed, but normally line 444 throws \"Please input all fields\" first.","commonSituations":"User clears the slug field in the status page editor but the form still submits; whitespace-only slug pasted from clipboard; frontend form validation disabled or skipped; a migration/import script that writes status pages with blank slugs.","solutions":["Make the slug field required on the client and disable submit while it is empty or whitespace-only.","Trim and reject empty slugs before emitting: `if (!String(config.slug).trim()) return;`.","If importing/migrating status pages, generate a fallback slug from the title (lowercased, hyphenated) when blank.","Audit stored status_page rows for empty slug values: `SELECT * FROM status_page WHERE slug IS NULL OR trim(slug) = ''`."],"exampleFix":"// before\nsocket.emit(\"saveStatusPage\", slug, { slug: \"   \", title: \"My Page\" }, ...);\n\n// after\nconst slugVal = String(config.slug ?? \"\").trim();\nif (!slugVal) { alert(\"Slug is required\"); return; }\nsocket.emit(\"saveStatusPage\", slug, { ...config, slug: slugVal }, ...);","handlingStrategy":"validation","validationCode":"const slug = typeof config.slug === \"string\" ? config.slug.trim() : \"\";\nif (!slug) { callback({ ok: false, msg: \"Slug is required\" }); return; }","typeGuard":"const isNonEmptyString = (v) => typeof v === \"string\" && v.trim().length > 0;","tryCatchPattern":"try { checkSlug(slug); } catch (e) { if (e.message === \"Slug cannot be empty\") { /* prompt user */ } throw e; }","preventionTips":["Make the slug field required in the form and disable submit when blank.","Trim on input change so whitespace-only is visible.","On import, derive a slug from the title when blank."],"tags":["status-page","slug","validation","socket","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}