From 927aebbd0b0463deac4ad0d96f4af474c59cb75c Mon Sep 17 00:00:00 2001
From: Antoine Lambert <anlambert@softwareheritage.org>
Date: Tue, 3 Sep 2024 12:04:12 +0200
Subject: [PATCH] sourceforge: Also skip ConnectionError when fetching project
 info

The sourceforge lister sends various HTTP requests to get info about a
project, for instance to get the branch name of a Bazaar project.

If HTTP errors occurred during these steps, they were discarded in order
for the listing to continue but connection errors were not and as a
consequence the listing was failing when encountering such error.

Currently, the legacy Bazaar project hosted on sourceforge seems down and
connection  errors are raised when attempting to fetch branch names so the
lister does not process all projects as it crashes in mid-flight.
---
 swh/lister/sourceforge/lister.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/swh/lister/sourceforge/lister.py b/swh/lister/sourceforge/lister.py
index 3d19894c..17592f2d 100644
--- a/swh/lister/sourceforge/lister.py
+++ b/swh/lister/sourceforge/lister.py
@@ -336,7 +336,7 @@ class SourceForgeLister(Lister[SourceForgeListerState, SourceForgeListerPage]):
 
         try:
             res = self.http_request(endpoint).json()
-        except requests.HTTPError:
+        except (requests.HTTPError, ConnectionError):
             # We've already logged in `http_request`
             return []
 
@@ -358,7 +358,7 @@ class SourceForgeLister(Lister[SourceForgeListerState, SourceForgeListerPage]):
                 cvs_info_url = f"http://{project}.cvs.sourceforge.net"
                 try:
                     response = self.http_request(cvs_info_url)
-                except requests.HTTPError:
+                except (requests.HTTPError, ConnectionError):
                     logger.warning(
                         "CVS info page could not be fetched, skipping project '%s'",
                         project,
@@ -420,7 +420,7 @@ class SourceForgeLister(Lister[SourceForgeListerState, SourceForgeListerPage]):
                                     )
                                 )
                         continue
-                except requests.HTTPError:
+                except (requests.HTTPError, ConnectionError):
                     logger.warning(
                         "Bazaar repository page could not be fetched, skipping project '%s'",
                         project,
-- 
GitLab