From 7f94ac29f461d32236a57442d9cb3dc8865492bd Mon Sep 17 00:00:00 2001 From: Angel98518 Date: Fri, 9 Jan 2026 06:10:06 +0100 Subject: [PATCH 1/7] Fix ping monitor interval reset issue Fixes #6657 Problem: When users set a ping monitor interval below the calculated minimum (based on ping configuration) and confirmed the warning, the interval was being reset back to a higher value after saving. This happened because finishUpdateInterval() was automatically adjusting the interval when monitor data was reloaded from the server after save. Solution: Added isLoadingMonitor flag to track when monitor data is being loaded vs when user is actively editing. The automatic interval adjustment in finishUpdateInterval() now skips when: 1. Monitor data is being loaded from server (isLoadingMonitor=true) 2. User has explicitly edited the interval (editedValue=true) This ensures that user-confirmed low intervals are respected and not automatically increased during the save/reload cycle. Changes: - Added isLoadingMonitor flag to component data - Set flag during init() when loading monitor data - Clear flag after monitor data is fully loaded using nextTick() - Updated finishUpdateInterval() to check both flags before auto-adjusting --- src/pages/EditMonitor.vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 3e7ac832e..4dea455a5 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -2393,6 +2393,7 @@ export default { confirmed: false, editedValue: false, }, + isLoadingMonitor: false, }; }, @@ -2915,6 +2916,7 @@ message HealthCheckResponse { } } + this.isLoadingMonitor = true; this.monitor = res.monitor; if (this.isClone) { @@ -2958,6 +2960,11 @@ message HealthCheckResponse { this.monitor.timeout = ~~(this.monitor.interval * 8) / 10; } } + + // Reset loading flag after all reactive updates + this.$nextTick(() => { + this.isLoadingMonitor = false; + }); } else { this.$root.toastError(res.msg); } @@ -3314,8 +3321,11 @@ message HealthCheckResponse { // Calculate the minimum required interval based on ping configuration const calculatedPingInterval = this.calculatePingInterval(); - // If the configured interval is too small, adjust it to the minimum required value - if (this.monitor.interval < calculatedPingInterval) { + // Don't auto-adjust interval when: + // 1. Loading monitor data from server (isLoadingMonitor flag) + // 2. User explicitly edited the interval value (editedValue flag) + // This respects the user's choice of low intervals they've confirmed + if (!this.isLoadingMonitor && !this.lowIntervalConfirmation.editedValue && this.monitor.interval < calculatedPingInterval) { this.monitor.interval = calculatedPingInterval; // Notify the user that the interval has been automatically adjusted From 472b1c400115124e9531833384c687dae7fcc7ee Mon Sep 17 00:00:00 2001 From: Angel98518 Date: Tue, 20 Jan 2026 06:47:51 +0100 Subject: [PATCH 2/7] fix: MongoDB monitor JSON.parse error handling Add proper error handling for invalid JSON in databaseQuery field. Previously, invalid JSON would cause an unhandled error. Now it provides a clear error message to the user. --- server/monitor-types/mongodb.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/monitor-types/mongodb.js b/server/monitor-types/mongodb.js index bbe217c64..cf2ca4ca3 100644 --- a/server/monitor-types/mongodb.js +++ b/server/monitor-types/mongodb.js @@ -12,7 +12,11 @@ class MongodbMonitorType extends MonitorType { async check(monitor, heartbeat, _server) { let command = { ping: 1 }; if (monitor.databaseQuery) { - command = JSON.parse(monitor.databaseQuery); + try { + command = JSON.parse(monitor.databaseQuery); + } catch (error) { + throw new Error(`Invalid JSON in database query: ${error.message}`); + } } let result = await this.runMongodbCommand(monitor.databaseConnectionString, command); From c3d7b6a9896484d20e6124f3522106b2640ce4dd Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 20 Jan 2026 06:00:51 +0000 Subject: [PATCH 3/7] [autofix.ci] apply automated fixes --- src/pages/EditMonitor.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 4dea455a5..0759ce70e 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -3325,7 +3325,11 @@ message HealthCheckResponse { // 1. Loading monitor data from server (isLoadingMonitor flag) // 2. User explicitly edited the interval value (editedValue flag) // This respects the user's choice of low intervals they've confirmed - if (!this.isLoadingMonitor && !this.lowIntervalConfirmation.editedValue && this.monitor.interval < calculatedPingInterval) { + if ( + !this.isLoadingMonitor && + !this.lowIntervalConfirmation.editedValue && + this.monitor.interval < calculatedPingInterval + ) { this.monitor.interval = calculatedPingInterval; // Notify the user that the interval has been automatically adjusted From a2f21ecb7d6748db971abc2d60cbeb6f72b3b936 Mon Sep 17 00:00:00 2001 From: Angel98518 Date: Tue, 20 Jan 2026 07:09:09 +0100 Subject: [PATCH 4/7] fix: Move MongoDB JSON validation to Monitor.validate() Move databaseQuery JSON validation from mongodb.js check() method to Monitor.validate() to follow the same pattern as other monitor types (e.g., ping monitor validations). This ensures validation happens at the model level before the check is executed. --- server/model/monitor.js | 9 +++++++++ server/monitor-types/mongodb.js | 7 ++----- 2 files changed, 11 insertions(+), 5 deletions(-) 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}`); + } + } } /** diff --git a/server/monitor-types/mongodb.js b/server/monitor-types/mongodb.js index cf2ca4ca3..7a78edab4 100644 --- a/server/monitor-types/mongodb.js +++ b/server/monitor-types/mongodb.js @@ -12,11 +12,8 @@ class MongodbMonitorType extends MonitorType { async check(monitor, heartbeat, _server) { let command = { ping: 1 }; if (monitor.databaseQuery) { - try { - command = JSON.parse(monitor.databaseQuery); - } catch (error) { - throw new Error(`Invalid JSON in database query: ${error.message}`); - } + // databaseQuery is validated in Monitor.validate(), so we can safely parse it here + command = JSON.parse(monitor.databaseQuery); } let result = await this.runMongodbCommand(monitor.databaseConnectionString, command); From 201ee920d1de74508abbc866dee2bebe1e1a4f12 Mon Sep 17 00:00:00 2001 From: Angel98518 Date: Tue, 20 Jan 2026 07:05:41 -0800 Subject: [PATCH 5/7] Update server/monitor-types/mongodb.js Co-authored-by: Frank Elsinga --- server/monitor-types/mongodb.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server/monitor-types/mongodb.js b/server/monitor-types/mongodb.js index 7a78edab4..bbe217c64 100644 --- a/server/monitor-types/mongodb.js +++ b/server/monitor-types/mongodb.js @@ -12,7 +12,6 @@ class MongodbMonitorType extends MonitorType { async check(monitor, heartbeat, _server) { let command = { ping: 1 }; if (monitor.databaseQuery) { - // databaseQuery is validated in Monitor.validate(), so we can safely parse it here command = JSON.parse(monitor.databaseQuery); } From 166a1901b9b824e54dacb41a32ffbaf8ad0ffa47 Mon Sep 17 00:00:00 2001 From: Angel98518 Date: Wed, 21 Jan 2026 15:03:30 +0100 Subject: [PATCH 6/7] Revert formatting change to keep PR focused on MongoDB validation only --- src/pages/EditMonitor.vue | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 0759ce70e..4dea455a5 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -3325,11 +3325,7 @@ message HealthCheckResponse { // 1. Loading monitor data from server (isLoadingMonitor flag) // 2. User explicitly edited the interval value (editedValue flag) // This respects the user's choice of low intervals they've confirmed - if ( - !this.isLoadingMonitor && - !this.lowIntervalConfirmation.editedValue && - this.monitor.interval < calculatedPingInterval - ) { + if (!this.isLoadingMonitor && !this.lowIntervalConfirmation.editedValue && this.monitor.interval < calculatedPingInterval) { this.monitor.interval = calculatedPingInterval; // Notify the user that the interval has been automatically adjusted From def053af7950e5de85b7194884adb04af518cab6 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 21 Jan 2026 14:04:56 +0000 Subject: [PATCH 7/7] [autofix.ci] apply automated fixes --- src/pages/EditMonitor.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 4dea455a5..0759ce70e 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -3325,7 +3325,11 @@ message HealthCheckResponse { // 1. Loading monitor data from server (isLoadingMonitor flag) // 2. User explicitly edited the interval value (editedValue flag) // This respects the user's choice of low intervals they've confirmed - if (!this.isLoadingMonitor && !this.lowIntervalConfirmation.editedValue && this.monitor.interval < calculatedPingInterval) { + if ( + !this.isLoadingMonitor && + !this.lowIntervalConfirmation.editedValue && + this.monitor.interval < calculatedPingInterval + ) { this.monitor.interval = calculatedPingInterval; // Notify the user that the interval has been automatically adjusted