From f1d3e9adcc49faef97570d55add4fa5e62562ac5 Mon Sep 17 00:00:00 2001 From: Angel98518 Date: Thu, 22 Jan 2026 13:18:10 +0800 Subject: [PATCH] fix: MongoDB monitor JSON.parse error handling (#6778) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Frank Elsinga --- server/model/monitor.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/model/monitor.js b/server/model/monitor.js index 3b8d89dd4..2719b89a0 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -1857,6 +1857,15 @@ class Monitor extends BeanModel { } } } + + if (this.type === "mongodb" && this.databaseQuery) { + // Validate that databaseQuery is valid JSON + try { + JSON.parse(this.databaseQuery); + } catch (error) { + throw new Error(`Invalid JSON in database query: ${error.message}`); + } + } } /**