mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-01-31 11:03:11 +08:00
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:
@@ -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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user