{"record":{"id":"0271c30a222d4fd9","repo":"louislam/uptime-kuma","slug":"response-max-length-cannot-be-less-than-0","errorCode":null,"errorMessage":"Response max length cannot be less than 0","messagePattern":"Response max length cannot be less than 0","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/model/monitor.js","lineNumber":1636,"sourceCode":"    }\n\n    /**\n     * Validate monitor configuration\n     * @returns {void}\n     * @throws {Error} If validation fails\n     */\n    validate() {\n        if (this.interval < MIN_INTERVAL_SECOND) {\n            throw new Error(`Interval cannot be less than ${MIN_INTERVAL_SECOND} seconds`);\n        }\n\n        if (this.retryInterval < MIN_INTERVAL_SECOND) {\n            throw new Error(`Retry interval cannot be less than ${MIN_INTERVAL_SECOND} seconds`);\n        }\n\n        if (this.response_max_length !== undefined) {\n            if (this.response_max_length < 0) {\n                throw new Error(`Response max length cannot be less than 0`);\n            }\n\n            if (this.response_max_length > RESPONSE_BODY_LENGTH_MAX) {\n                throw new Error(`Response max length cannot be more than ${RESPONSE_BODY_LENGTH_MAX} bytes`);\n            }\n        }\n\n        // Validate JSON fields to prevent invalid JSON from being stored in database\n        if (this.kafkaProducerBrokers) {\n            try {\n                JSON.parse(this.kafkaProducerBrokers);\n            } catch (e) {\n                throw new Error(`Kafka Producer Brokers must be valid JSON: ${e.message}`);\n            }\n        }\n\n        if (this.kafkaProducerSaslOptions) {\n            try {","sourceCodeStart":1618,"sourceCodeEnd":1654,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/model/monitor.js#L1618-L1654","documentation":"validate() rejects a negative response_max_length. The field, when defined, must be 0 (meaning unlimited handling internally) or a positive byte count.","triggerScenarios":"Saving a monitor with response_max_length set to a negative number.","commonSituations":"Manual API/script passing a bad numeric value; form corruption; a -1 sentinel from another system.","solutions":["Set response_max_length to 0 for unlimited, or a positive byte count","Validate that numeric inputs are non-negative before submitting the form"],"exampleFix":"// before\nmonitor.response_max_length = -1;\n\n// after\nmonitor.response_max_length = 0;","handlingStrategy":"validation","validationCode":"if (monitor.response_max_length !== undefined && monitor.response_max_length < 0) throw new Error(\"response_max_length must be >= 0\");","typeGuard":"function isValidResponseMaxLength(v) { return v === undefined || (Number.isFinite(v) && v >= 0); }","tryCatchPattern":"try { await socket.emit(\"addMonitor\", payload); } catch (e) { /* surface e.message */ }","preventionTips":["Reject negative numerics at the form/API boundary","Use 0 to express unlimited rather than sentinel negative values"],"tags":["validation","config"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}