{"record":{"id":"536298c6f32824b1","repo":"louislam/uptime-kuma","slug":"invalid-slug","errorCode":null,"errorMessage":"Invalid Slug","messagePattern":"Invalid Slug","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/socket-handlers/status-page-socket-handler.js","lineNumber":545,"sourceCode":" * 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":527,"sourceCodeEnd":548,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/socket-handlers/status-page-socket-handler.js#L527-L548","documentation":"Thrown by checkSlug() when the slug fails the regex `^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`. Allowed: one or more alphanumerics, optionally followed by groups of a single hyphen plus alphanumerics. Forbidden: underscores, dots, slashes, spaces, leading/trailing hyphens, consecutive hyphens. The slug becomes the public URL path of a status page, so it must be URL-safe and unambiguous.","triggerScenarios":"saveStatusPage (or createStatusPage) with a slug containing `_`, `.`, `/`, ` `, capital-only is fine but any special character fails; slugs like \"my page\", \"my_page\", \"-lead\", \"double--hyphen\", \"trailing-\", \"api/v2\" all throw. Note createStatusPage lowercases first (line 454) but the regex itself is case-insensitive via A-Za-z, so case is not the cause.","commonSituations":"User copies a slug from a CMS that allows underscores; attempt to nest status pages with slashes; trailing hyphen from auto-generating slug from a title ending in a dash; migration from a system with different slug rules.","solutions":["Sanitize the slug to the allowed charset before submitting: lowercase, replace any non-alphanumeric run with a single hyphen, trim leading/trailing hyphens.","Show live regex feedback in the editor so the user sees the rule before submit.","Reuse a shared slugify helper for both create and save paths.","Document the slug rule on the input field: 'Letters, numbers, and single hyphens only.'"],"exampleFix":"// before\nconst slug = \"My_Status_Page\";\n\n// after\nfunction slugify(input) {\n  return String(input)\n    .trim()\n    .replace(/[^A-Za-z0-9]+/g, \"-\")\n    .replace(/^-+|-+$/g, \"\");\n}\nconst slug = slugify(\"My_Status_Page\"); // \"My-Status-Page\"","handlingStrategy":"validation","validationCode":"const SLUG_RE = /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/;\nif (!SLUG_RE.test(slug)) { throw new Error(\"Slug must be letters, numbers, single hyphens\"); }","typeGuard":"const isValidSlug = (v) => typeof v === \"string\" && /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/.test(v);","tryCatchPattern":"try { checkSlug(slug); } catch (e) { if (e.message === \"Invalid Slug\") showFieldError(\"slug\", e.message); else throw e; }","preventionTips":["Show live regex feedback in the editor.","Run the value through slugify() (replace non-alnum runs with single hyphen, trim) before submit.","Reuse the exact server regex on the client to avoid drift."],"tags":["status-page","slug","validation","regex","socket","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}