{"record":{"id":"939573e506091154","repo":"louislam/uptime-kuma","slug":"invalid-pm2-process-name","errorCode":null,"errorMessage":"Invalid PM2 process name.","messagePattern":"Invalid PM2 process name\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/model/monitor.js","lineNumber":1706,"sourceCode":"            } 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)\n            ) {\n                throw new Error(\n                    `Per-ping timeout must be between ${PING_PER_REQUEST_TIMEOUT_MIN} and ${PING_PER_REQUEST_TIMEOUT_MAX} seconds (default: ${PING_PER_REQUEST_TIMEOUT_DEFAULT})`\n                );","sourceCodeStart":1688,"sourceCodeEnd":1724,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/model/monitor.js#L1688-L1724","documentation":"Thrown by Monitor.validate() for type \"pm2\" when system_service_name contains a C0 control character (\\u0000-\\u001F) or DEL (\\u007F). PM2 process names are passed to the pm2 process manager and CLI, where control characters corrupt output or argument parsing. Unlike system-service, PM2 allows spaces and most printable characters, so only invisible control bytes are rejected.","triggerScenarios":"Save a pm2 monitor whose process name was copied from a terminal/log line containing a stray \\r, \\n, \\t, NUL, or DEL byte. Programmatically constructed names that embed escape sequences or unsplit newline-delimited lists.","commonSituations":"Pasting the process name from `pm2 list` output where a terminal wrapped a carriage return into the selection; importing monitors from a CSV that was edited in a spreadsheet adding non-breaking/control chars; build pipelines injecting \\n into names.","solutions":["Sanitize the name by removing \\u0000-\\u001F and \\u007F, e.g. name.replace(/[\\u0000-\\u001F\\u007F]/g, \"\").","Re-type the PM2 process name by hand rather than copy-pasting from terminal output.","Run `pm2 jlist` and copy the `name` field verbatim to ensure a clean value."],"exampleFix":"// before\nconst name = rawPm2Line; // contains trailing \\r\n// after\nconst name = rawPm2Line.replace(/[\\u0000-\\u001F\\u007F]/g, \"\").trim();","handlingStrategy":"validation","validationCode":"function cleanPm2Name(name) {\n  return String(name || \"\").replace(/[\\u0000-\\u001F\\u007F]/g, \"\").trim();\n}\nmonitor.system_service_name = cleanPm2Name(monitor.system_service_name);","typeGuard":"function isCleanPm2Name(name) {\n  return typeof name === \"string\" && name.length > 0 && !/[\\u0000-\\u001F\\u007F]/.test(name);\n}","tryCatchPattern":"try {\n  await bean.validate();\n} catch (e) {\n  if (/Invalid PM2 process name/.test(e.message)) {\n    monitor.system_service_name = monitor.system_service_name.replace(/[\\u0000-\\u001F\\u007F]/g, \"\");\n    return retry();\n  }\n  throw e;\n}","preventionTips":["Always strip C0 control bytes and DEL from any paste-in name.","Pull names verbatim from `pm2 jlist`."],"tags":["monitor","pm2","validation","sanitization","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}