Skip to content

Commit 3bbf3ff

Browse files
author
Vladimir Smirnov
committed
Fix panic in case if filter's regex is not defined
1 parent 94c59f5 commit 3bbf3ff

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

feeds/process.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,20 @@ func (f *Feed) processSingleItem(cfg *configs.FeedsConfig, url string, item *gof
140140
logger = logger.With(
141141
zap.Int("filter_id", i),
142142
zap.String("filter", cfg.Filters[i].Filter),
143-
zap.String("filter_regex_string", cfg.Filters[i].FilterRegex.String()),
144143
zap.Time("filter_last_update_time", cfg.Filters[i].LastUpdateTime),
145144
)
145+
146+
if cfg.Filters[i].FilterRegex == nil {
147+
logger.Error("regex not defined for package",
148+
zap.String("reason", "some bug caused filter not to be defined. This should never happen"),
149+
)
150+
continue
151+
}
152+
153+
logger = logger.With(
154+
zap.String("filter_regex_string", cfg.Filters[i].FilterRegex.String()),
155+
)
156+
146157
logger.Debug("will test for filter")
147158

148159
if cfg.Filters[i].LastUpdateTime.Unix() >= item.UpdatedParsed.Unix() {
@@ -154,12 +165,7 @@ func (f *Feed) processSingleItem(cfg *configs.FeedsConfig, url string, item *gof
154165
continue
155166
}
156167

157-
if cfg.Filters[i].FilterRegex == nil {
158-
logger.Error("regex not defined for package",
159-
zap.String("reason", "some bug caused filter not to be defined. This should never happen"),
160-
)
161-
continue
162-
}
168+
163169

164170
if cfg.Filters[i].FilterRegex.MatchString(item.Title) {
165171
logger.Debug("filter matched")

0 commit comments

Comments
 (0)