louislam/uptime-kuma · warning · Error
Slug -Accept string only
Error message
Slug -Accept string only
What it means
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.
Source
Thrown at server/socket-handlers/status-page-socket-handler.js:450
}
});
// Add a new status page
socket.on("addStatusPage", async (title, slug, callback) => {
try {
checkLogin(socket);
title = title?.trim();
slug = slug?.trim();
// Check empty
if (!title || !slug) {
throw new Error("Please input all fields");
}
// Make sure slug is string
if (typeof slug !== "string") {
throw new Error("Slug -Accept string only");
}
// lower case only
slug = slug.toLowerCase();
checkSlug(slug);
let statusPage = R.dispense("status_page");
statusPage.slug = slug;
statusPage.title = title;
statusPage.theme = "auto";
statusPage.icon = "";
statusPage.autoRefreshInterval = 300;
await R.store(statusPage);
callback({
ok: true,
msg: "successAdded",View on GitHub (pinned to 6b5ea01557)
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.
Example fix
// before
socket.emit("addStatusPage", "Main", 123, cb);
// after
socket.emit("addStatusPage", "Main", "123", cb); Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof slug !== "string") slug = String(slug);
socket.emit("addStatusPage", title, slug, cb); Type guard
function isStringSlug(slug) {
return typeof slug === "string";
} Try / catch
try { await emitAsync("addStatusPage", title, slug, cb); }
catch (e) { if (/Accept string only/.test(e.message)) retryWithStringSlug(); else throw e; } Prevention
- Always coerce slug to string on the client.
- Validate typeof slug === 'string' before emit.
- Keep the API contract typed (slug: string).
When it happens
Trigger: 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'.
Common situations: Client coercion bug (slug parsed as number from URL); JSON payload built dynamically with a numeric slug; type confusion between client and server contract.
Related errors
AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12).
Data as JSON: /api/errors/754ec8fc5b20118c.
Report an issue: GitHub.