{"record":{"id":"2493876f095150cf","repo":"louislam/uptime-kuma","slug":"service-name-is-required","errorCode":null,"errorMessage":"Service Name is required.","messagePattern":"Service Name is required\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/model/monitor.js","lineNumber":1697,"sourceCode":"                JSON.parse(this.headers);\n            } catch (e) {\n                throw new Error(`Headers must be valid JSON: ${e.message}`);\n            }\n        }\n\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            }","sourceCodeStart":1679,"sourceCodeEnd":1715,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/model/monitor.js#L1679-L1715","documentation":"Thrown by Monitor.validate() in server/model/monitor.js when a monitor of type \"system-service\" is created or updated with an empty system_service_name. The field is trimmed before the check, so a whitespace-only value also triggers it. Uptime-Kuma requires the systemd/init service unit name to query the host's service manager.","triggerScenarios":"POST/PUT to the monitor save/update Socket.IO or REST endpoint with {type:\"system-service\", system_service_name:\"\"} or {type:\"system-service\"} with the field omitted/whitespace. The branch is only entered for types in [\"system-service\",\"pm2\"], and the ternary picks this exact message when type !== \"pm2\".","commonSituations":"User selects the \"System Service\" monitor type in the Uptime-Kuma UI but forgets to fill the service name field; or an API/automation script POSTs the monitor payload without mapping the service name. Migrating monitors where the field was previously nullable.","solutions":["Set system_service_name to the internal systemd unit name, e.g. \"nginx.service\" or \"ssh\".","If building the payload programmatically, ensure the field is a non-empty string after .trim() before sending.","Confirm the monitor type is actually \"system-service\" and not mislabeled as another type that does not use this field."],"exampleFix":"// before\n{ type: \"system-service\", system_service_name: \"\" }\n// after\n{ type: \"system-service\", system_service_name: \"nginx.service\" }","handlingStrategy":"validation","validationCode":"function isValidSystemServiceName(name) {\n  return typeof name === \"string\" && name.trim().length > 0;\n}\nif (monitor.type === \"system-service\" && !isValidSystemServiceName(monitor.system_service_name)) {\n  throw new Error(\"system_service_name required before save\");\n}","typeGuard":"function isSystemServiceInput(m) {\n  return m && m.type === \"system-service\" && typeof m.system_service_name === \"string\" && m.system_service_name.trim().length > 0;\n}","tryCatchPattern":"try {\n  await bean.validate();\n} catch (e) {\n  if (/Service Name is required/.test(e.message)) {\n    return badRequest(\"system_service_name is required\");\n  }\n  throw e;\n}","preventionTips":["Make the service-name field required in the form when type is system-service.","Pre-trim and assert non-empty in your API layer before calling Monitor.validate()."],"tags":["monitor","system-service","validation","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}