{"record":{"id":"66157c5e22a15111","repo":"louislam/uptime-kuma","slug":"invalid-service-name-please-use-the-internal-serv","errorCode":null,"errorMessage":"Invalid service name. Please use the internal Service Name (no spaces).","messagePattern":"Invalid service name\\. Please use the internal Service Name \\(no spaces\\)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/model/monitor.js","lineNumber":1702,"sourceCode":"\n        if (this.accepted_statuscodes_json) {\n            try {\n                JSON.parse(this.accepted_statuscodes_json);\n            } catch (e) {\n                throw new Error(`Accepted status codes must be valid JSON: ${e.message}`);\n            }\n        }\n\n        if ([\"system-service\", \"pm2\"].includes(this.type)) {\n            this.system_service_name = (this.system_service_name || \"\").trim();\n\n            if (!this.system_service_name) {\n                throw new Error(this.type === \"pm2\" ? \"PM2 process name is required.\" : \"Service Name is required.\");\n            }\n        }\n\n        if (this.type === \"system-service\" && !/^[a-zA-Z0-9._\\-@]+$/.test(this.system_service_name)) {\n            throw new Error(\"Invalid service name. Please use the internal Service Name (no spaces).\");\n        }\n\n        if (this.type === \"pm2\" && /[\\u0000-\\u001F\\u007F]/.test(this.system_service_name)) {\n            throw new Error(\"Invalid PM2 process name.\");\n        }\n\n        if (this.type === \"ping\") {\n            // ping parameters validation\n            if (this.packetSize && (this.packetSize < PING_PACKET_SIZE_MIN || this.packetSize > PING_PACKET_SIZE_MAX)) {\n                throw new Error(\n                    `Packet size must be between ${PING_PACKET_SIZE_MIN} and ${PING_PACKET_SIZE_MAX} (default: ${PING_PACKET_SIZE_DEFAULT})`\n                );\n            }\n\n            if (\n                this.ping_per_request_timeout &&\n                (this.ping_per_request_timeout < PING_PER_REQUEST_TIMEOUT_MIN ||\n                    this.ping_per_request_timeout > PING_PER_REQUEST_TIMEOUT_MAX)","sourceCodeStart":1684,"sourceCodeEnd":1720,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/model/monitor.js#L1684-L1720","documentation":"Thrown by Monitor.validate() when a \"system-service\" monitor's system_service_name contains characters outside the set [a-zA-Z0-9._\\-@]. This guards the value because it is passed to the service manager; spaces, slashes, shell metacharacters, or unicode break the lookup and risk injection.","triggerScenarios":"Save a system-service monitor whose name fails /^[a-zA-Z0-9._\\-@]+$/. Common failing inputs: \"nginx service\" (space), \"nginx.service \" (trailing space is trimmed, but other whitespace mid-string fails), \"user@host:80\" (colon not allowed), names with \"/\" or \"%\".","commonSituations":"User enters the human-readable display name (\"Web Server\") instead of the internal unit name (\"nginx.service\"). Copying a value from a URL or path that contains disallowed characters. Locale-specific unicode in service names.","solutions":["Use the internal service unit name reported by `systemctl list-units --type=service`, e.g. \"nginx.service\".","Strip spaces and shell metacharacters from the value before saving.","If the name legitimately needs a disallowed character, alias/wrap the service so its unit name matches the allowed set."],"exampleFix":"// before\n{ type: \"system-service\", system_service_name: \"Web Server (prod)\" }\n// after\n{ type: \"system-service\", system_service_name: \"nginx.service\" }","handlingStrategy":"validation","validationCode":"const SERVICE_NAME_RE = /^[a-zA-Z0-9._\\-@]+$/;\nfunction validServiceName(name) {\n  return typeof name === \"string\" && SERVICE_NAME_RE.test(name);\n}","typeGuard":"function isAllowedServiceName(name) {\n  return typeof name === \"string\" && /^[a-zA-Z0-9._\\-@]+$/.test(name);\n}","tryCatchPattern":"try {\n  await bean.validate();\n} catch (e) {\n  if (/Invalid service name/.test(e.message)) {\n    return badRequest(\"Use the internal service unit name (no spaces)\");\n  }\n  throw e;\n}","preventionTips":["Surface the allowed character set in the UI hint next to the field.","Resolve unit names from `systemctl list-units` rather than free-text entry."],"tags":["monitor","system-service","validation","sanitization","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}