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 <frank@elsinga.de>
This commit is contained in:
Angel98518
2026-01-22 13:18:10 +08:00
committed by GitHub
parent 9169a647cb
commit f1d3e9adcc

View File

@@ -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}`);
}
}
}
/**