{"record":{"id":"76439d301424185c","repo":"louislam/uptime-kuma","slug":"service-name-is-required-76439d","errorCode":null,"errorMessage":"Service Name is required.","messagePattern":"Service Name is required\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/monitor-types/system-service.js","lineNumber":21,"sourceCode":"const process = require(\"process\");\nconst { UP } = require(\"../../src/util\");\n\nclass SystemServiceMonitorType extends MonitorType {\n    name = \"system-service\";\n    description = \"Checks if a system service is running (systemd on Linux, Service Manager on Windows).\";\n\n    /**\n     * Check the system service status.\n     * Detects OS and dispatches to the appropriate check method.\n     * @param {object} monitor The monitor object containing monitor.system_service_name.\n     * @param {object} heartbeat The heartbeat object to update.\n     * @returns {Promise<void>} Resolves when check is complete.\n     */\n    async check(monitor, heartbeat) {\n        const serviceName = (monitor.system_service_name || \"\").trim();\n\n        if (!serviceName) {\n            throw new Error(\"Service Name is required.\");\n        }\n\n        if (process.platform === \"win32\") {\n            return this.checkWindows(serviceName, heartbeat);\n        } else if (process.platform === \"linux\") {\n            return this.checkLinux(serviceName, heartbeat);\n        }\n\n        throw new Error(`System Service monitoring is not supported on ${process.platform}`);\n    }\n\n    /**\n     * Linux Check (Systemd)\n     * @param {string} serviceName The name of the service to check.\n     * @param {object} heartbeat The heartbeat object.\n     * @returns {Promise<void>}\n     */\n    async checkLinux(serviceName, heartbeat) {","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/monitor-types/system-service.js#L3-L39","documentation":"Thrown by SystemServiceMonitorType.check() when monitor.system_service_name is null, undefined, or whitespace-only after trimming. The service name is required input for both the systemd (Linux) and Service Manager (Windows) code paths, so without it the check cannot construct a valid command.","triggerScenarios":"Produced at the top of check() before any platform dispatch, whenever the monitor was created/saved without a system_service_name value or the field contains only whitespace.","commonSituations":"Monitor created via API/migration that omitted system_service_name; frontend field left blank; an automation script creating a monitor of type 'system-service' without setting the name; trim() removing a value that was only spaces.","solutions":["Edit the monitor and fill in the Service Name field with the real systemd unit or Windows service name.","If creating monitors programmatically, ensure system_service_name is set and non-empty before saving.","Add form-level validation so the monitor cannot be saved without a service name."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function requireServiceName(monitor) {\n  const name = (monitor?.system_service_name || \"\").trim();\n  if (!name) throw new Error(\"Service Name is required.\");\n  return name;\n}","typeGuard":"function hasServiceName(monitor) { return typeof monitor?.system_service_name === \"string\" && monitor.system_service_name.trim().length > 0; }","tryCatchPattern":"if (!hasServiceName(monitor)) { heartbeat.status = DOWN; heartbeat.msg = \"Service Name is required.\"; return; }","preventionTips":["Make the Service Name field required in the creation form.","When creating monitors via API, assert system_service_name is set.","Reject empty/whitespace values at save time."],"tags":["system-service","validation","configuration","input"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}