chore: handle error before using task (#6055)

This commit is contained in:
Srikanth Chekuri 2024-09-24 10:56:49 +05:30 committed by GitHub
parent 419d2da363
commit b49ed913c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -476,15 +476,15 @@ func (m *Manager) addTask(rule *PostableRule, taskName string) error {
UseLogsNewSchema: m.opts.UseLogsNewSchema,
})
for _, r := range newTask.Rules() {
m.rules[r.ID()] = r
}
if err != nil {
zap.L().Error("creating rule task failed", zap.String("name", taskName), zap.Error(err))
return errors.New("error loading rules, previous rule set restored")
}
for _, r := range newTask.Rules() {
m.rules[r.ID()] = r
}
// If there is an another task with the same identifier, raise an error
_, ok := m.tasks[taskName]
if ok {