fix(monitors): 400/404 on bad updates, clamp for_sec, reset heartbeat state on re-enable

This commit is contained in:
2026-09-17 09:24:16 +00:00
parent 753ba09e6e
commit 2701b32b5f
3 changed files with 100 additions and 11 deletions
+7
View File
@@ -145,6 +145,8 @@ func getMonitor(c *gin.Context) {
// @Param body body object{name=string,group=string,type=string,target=models.MonitorTarget,interval_sec=int,runner=string,retries=int,enabled=bool,channel_ids=[]string,for_sec=int} true "Fields to update"
// @Success 204
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 404 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Security cookieAuth
// @Security bearerAuth
@@ -210,6 +212,10 @@ func updateMonitor(c *gin.Context) {
c.JSON(http.StatusForbidden, gin.H{"error": err.Error()})
return
}
if errors.Is(err, services.ErrMonitorNotFound) {
c.JSON(http.StatusNotFound, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
@@ -222,6 +228,7 @@ func updateMonitor(c *gin.Context) {
// @Tags monitors
// @Param id path string true "Monitor ID"
// @Success 204
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Security cookieAuth
// @Security bearerAuth