{"record":{"id":"c5c33aa8eeea2f56","repo":"louislam/uptime-kuma","slug":"accepted-status-codes-must-be-valid-json-e-mess","errorCode":null,"errorMessage":"Accepted status codes must be valid JSON: ${e.message}","messagePattern":"Accepted status codes must be valid JSON: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/model/monitor.js","lineNumber":1689,"sourceCode":"                JSON.parse(this.conditions);\n            } catch (e) {\n                throw new Error(`Conditions must be valid JSON: ${e.message}`);\n            }\n        }\n\n        if (this.headers) {\n            try {\n                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        }","sourceCodeStart":1671,"sourceCodeEnd":1707,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/model/monitor.js#L1671-L1707","documentation":"validate() runs JSON.parse on accepted_statuscodes_json. It must be a JSON array of status-code range strings (e.g. [\"2xx\",\"3xx\"]).","triggerScenarios":"accepted_statuscodes_json is not valid JSON, e.g. a comma-separated string or a legacy non-JSON representation.","commonSituations":"Manual API call passing comma-separated codes; field populated by an older version or fork with a different format.","solutions":["Provide accepted status codes as a JSON array: [\"2xx\",\"3xx\"]","Validate with JSON.parse before saving"],"exampleFix":"// before\nmonitor.accepted_statuscodes_json = \"2xx,3xx\";\n\n// after\nmonitor.accepted_statuscodes_json = '[\"2xx\",\"3xx\"]';","handlingStrategy":"validation","validationCode":"if (monitor.accepted_statuscodes_json) {\n  const v = JSON.parse(monitor.accepted_statuscodes_json);\n  if (!Array.isArray(v)) throw new Error(\"accepted status codes must be a JSON array\");\n}","typeGuard":"function isValidStatusCodes(v) {\n  if (!v) return true;\n  try { return Array.isArray(JSON.parse(v)); } catch { return false; }\n}","tryCatchPattern":"try { monitor.validate(); await save(monitor); } catch (e) { /* surface e.message */ }","preventionTips":["Store accepted status codes as a JSON array like [\"2xx\",\"3xx\"]","Re-check this field after importing from forks or older versions"],"tags":["json","validation","config","http"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}