{"record":{"id":"1640201d5d6bc638","repo":"louislam/uptime-kuma","slug":"kafka-producer-brokers-must-be-valid-json-e-mes","errorCode":null,"errorMessage":"Kafka Producer Brokers must be valid JSON: ${e.message}","messagePattern":"Kafka Producer Brokers must be valid JSON: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/model/monitor.js","lineNumber":1649,"sourceCode":"            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 {\n                JSON.parse(this.kafkaProducerSaslOptions);\n            } catch (e) {\n                throw new Error(`Kafka Producer SASL Options must be valid JSON: ${e.message}`);\n            }\n        }\n\n        if (this.rabbitmqNodes) {\n            try {\n                JSON.parse(this.rabbitmqNodes);\n            } catch (e) {\n                throw new Error(`RabbitMQ Nodes must be valid JSON: ${e.message}`);\n            }\n        }","sourceCodeStart":1631,"sourceCodeEnd":1667,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/model/monitor.js#L1631-L1667","documentation":"validate() runs JSON.parse on kafkaProducerBrokers for kafka-producer monitors. It must be a JSON array of broker address strings (e.g. [\"host:9092\"]).","triggerScenarios":"kafkaProducerBrokers holds a non-JSON string such as a comma-separated list ('host1:9092,host2:9092') instead of a JSON array.","commonSituations":"Pasting a comma-separated broker list from kafka docs; stray quotes or a trailing comma.","solutions":["Provide brokers as a JSON array: [\"host:9092\"]","Run JSON.parse on the value in a console before saving to catch syntax errors"],"exampleFix":"// before\nmonitor.kafkaProducerBrokers = \"kafka:9092\";\n\n// after\nmonitor.kafkaProducerBrokers = '[\"kafka:9092\"]';","handlingStrategy":"validation","validationCode":"if (monitor.kafkaProducerBrokers) { JSON.parse(monitor.kafkaProducerBrokers); } // throws if invalid","typeGuard":"function isValidBrokers(v) {\n  if (!v) return true;\n  try { return Array.isArray(JSON.parse(v)) && JSON.parse(v).every(s => typeof s === \"string\"); }\n  catch { return false; }\n}","tryCatchPattern":"try { monitor.validate(); await save(monitor); } catch (e) { /* surface e.message */ }","preventionTips":["Always store brokers as a JSON array of strings","JSON.parse-check every JSON-typed field before saving"],"tags":["kafka","json","validation","config"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}