From 66fb3253f74e5c1e9f0859ca6c4c66f7473909c4 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 28 Nov 2016 10:38:58 +0000 Subject: [PATCH 1/2] Treat RSS feeds with 0 items as errors In the wild it looks like some RSS feeds will occasionally return 0 items to requests *but not return an error*. This previously meant we would clobber our knowledge of recent GUIDs with the empty set. This meant that the next successful poll would resend the **entire** RSS feed. --- src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go index 21c9b1d..0d21ab3 100644 --- a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go +++ b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go @@ -241,7 +241,9 @@ func (s *Service) queryFeed(feedURL string) (*gofeed.Feed, []gofeed.Item, error) fp := gofeed.NewParser() fp.Client = cachingClient feed, err := fp.ParseURL(feedURL) - if err != nil { + // check for no items in addition to any returned errors as it appears some RSS feeds + // do not consistently return items. + if err != nil || len(feed.Items) == 0 { f := s.Feeds[feedURL] f.IsFailing = true s.Feeds[feedURL] = f From 677b5563768ca1bda1dd9123eca8a25913b03705 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 28 Nov 2016 10:43:48 +0000 Subject: [PATCH 2/2] Return an error so it is logged --- src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go index 0d21ab3..5ddbe54 100644 --- a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go +++ b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go @@ -243,7 +243,11 @@ func (s *Service) queryFeed(feedURL string) (*gofeed.Feed, []gofeed.Item, error) feed, err := fp.ParseURL(feedURL) // check for no items in addition to any returned errors as it appears some RSS feeds // do not consistently return items. - if err != nil || len(feed.Items) == 0 { + if err == nil && len(feed.Items) == 0 { + err = errors.New("feed has 0 items") + } + + if err != nil { f := s.Feeds[feedURL] f.IsFailing = true s.Feeds[feedURL] = f