From bfea83ae7539b8758466b05553805e29c5157b0b Mon Sep 17 00:00:00 2001 From: qinguoyi <1532979219@qq.com> Date: Mon, 12 Aug 2024 13:06:58 +0800 Subject: [PATCH] fix: alert_cur_event return unmarshal json err (#2090) --- models/alert_cur_event.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/models/alert_cur_event.go b/models/alert_cur_event.go index ae8a3f9cc..248fe3511 100644 --- a/models/alert_cur_event.go +++ b/models/alert_cur_event.go @@ -305,8 +305,12 @@ func (e *AlertCurEvent) DB2FE() error { e.CallbacksJSON = strings.Fields(e.Callbacks) e.TagsJSON = strings.Split(e.Tags, ",,") e.OriginalTagsJSON = strings.Split(e.OriginalTags, ",,") - json.Unmarshal([]byte(e.Annotations), &e.AnnotationsJSON) - json.Unmarshal([]byte(e.RuleConfig), &e.RuleConfigJson) + if err := json.Unmarshal([]byte(e.Annotations), &e.AnnotationsJSON); err != nil { + return err + } + if err := json.Unmarshal([]byte(e.RuleConfig), &e.RuleConfigJson); err != nil { + return err + } return nil } @@ -617,8 +621,8 @@ func AlertCurEventGetMap(ctx *ctx.Context, cluster string) (map[int64]map[string return ret, nil } -func (m *AlertCurEvent) UpdateFieldsMap(ctx *ctx.Context, fields map[string]interface{}) error { - return DB(ctx).Model(m).Updates(fields).Error +func (e *AlertCurEvent) UpdateFieldsMap(ctx *ctx.Context, fields map[string]interface{}) error { + return DB(ctx).Model(e).Updates(fields).Error } func AlertCurEventUpgradeToV6(ctx *ctx.Context, dsm map[string]Datasource) error {