Skip to content

Commit

Permalink
fix: panic when template is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
710leo committed Apr 3, 2023
1 parent ee167ce commit 1ce79e2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions alert/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,18 +378,19 @@ func (p *Processor) fillTags(anomalyPoint common.AnomalyPoint) {
t, err := template.New(fmt.Sprint(p.rule.Id)).Funcs(template.FuncMap(tplx.TemplateFuncMap)).Parse(text)
if err != nil {
tagValue = fmt.Sprintf("parse tag value failed, err:%s", err)
tagsMap[arr[0]] = tagValue
continue
}

var body bytes.Buffer
err = t.Execute(&body, e)
if err != nil {
tagValue = fmt.Sprintf("parse tag value failed, err:%s", err)
tagsMap[arr[0]] = tagValue
continue
}

if err == nil {
tagValue = body.String()
}
tagsMap[arr[0]] = tagValue
tagsMap[arr[0]] = body.String()
}

tagsMap["rulename"] = p.rule.Name
Expand Down

0 comments on commit 1ce79e2

Please sign in to comment.