Repository: meltano/meltano

Issue:
bug: pre-commit fails in CI on files that we're not updated
PR https://github.com/meltano/meltano/pull/7385 updating only docs but fails CI tests because of these seemingly unrelated precommit tests https://results.pre-commit.ci/run/github/378997214/1678975479.B-Kg4nq3SzupwxvVY7Lkxw.


Discussion:
I'm not sure what the cause of this is. This has been fixed in the `cloud` branch. I'll cherry-pick the fix into `main` using a PR.

Resolving patch:
diff --git a/src/meltano/api/controllers/root.py b/src/meltano/api/controllers/root.py
--- a/src/meltano/api/controllers/root.py
+++ b/src/meltano/api/controllers/root.py
@@ -17,6 +17,8 @@
 from meltano.core.project import Project
 from meltano.core.utils import truthy
 
+REQUEST_TIMEOUT_SECONDS = 30.0
+
 logger = logging.getLogger(__name__)
 root = Blueprint("root", __name__)
 
@@ -76,8 +78,9 @@ def version():
 
     if truthy(request.args.get("include_latest")):
         try:
-            res = requests.get("https://pypi.org/pypi/meltano/json")
-            pypi_payload = res.json()
+            pypi_payload = requests.get(
+                "https://pypi.org/pypi/meltano/json", timeout=REQUEST_TIMEOUT_SECONDS
+            ).json()
             response_payload["latest_version"] = pypi_payload["info"]["version"]
         except requests.exceptions.ConnectionError as e:
             logger.warning(
diff --git a/src/meltano/api/workers/ui_available_worker.py b/src/meltano/api/workers/ui_available_worker.py
--- a/src/meltano/api/workers/ui_available_worker.py
+++ b/src/meltano/api/workers/ui_available_worker.py
@@ -12,6 +12,7 @@
 
 logger = logging.getLogger(__name__)
 
+REQUEST_TIMEOUT_SECONDS = 30.0
 SUCCESS_STATUS_CODE = 200
 
 
@@ -35,7 +36,11 @@ def run(self) -> None:
 
         while not self._terminate:
             try:
-                response = requests.get(url, headers=headers)
+                response = requests.get(
+                    url,
+                    headers=headers,
+                    timeout=REQUEST_TIMEOUT_SECONDS,
+                )
                 if response.status_code == SUCCESS_STATUS_CODE:
                     click.secho(f"Meltano UI is now available at {url}", fg="green")
                     self._terminate = True
diff --git a/src/meltano/core/plugin_discovery_service.py b/src/meltano/core/plugin_discovery_service.py
--- a/src/meltano/core/plugin_discovery_service.py
+++ b/src/meltano/core/plugin_discovery_service.py
@@ -7,6 +7,7 @@
 import re
 import typing as t
 from abc import ABCMeta, abstractmethod
+from contextlib import suppress
 
 import requests
 from ruamel.yaml import YAMLError
@@ -26,6 +27,8 @@
 if t.TYPE_CHECKING:
     from meltano.core.project import Project
 
+REQUEST_TIMEOUT_SECONDS = 30.0
+
 
 class DiscoveryInvalidError(Exception):
     """Occurs when the discovery.yml fails to be parsed."""
@@ -221,17 +224,15 @@ def discovery(self):
 
         raise DiscoveryInvalidError("No valid `discovery.yml` manifest could be found")
 
-    def load_local_discovery(self):
+    def load_local_discovery(self) -> DiscoveryFile | None:
         """Load the local `discovery.yml` manifest.
 
         Returns:
             The discovery file.
         """
-        try:
+        with suppress(FileNotFoundError):
             with self.project.root_dir("discovery.yml").open() as local_discovery:
                 return self.load_discovery(local_discovery)
-        except FileNotFoundError:
-            pass
 
     def load_remote_discovery(self) -> DiscoveryFile | None:
         """Load the remote `discovery.yml` manifest.
@@ -256,7 +257,12 @@ def load_remote_discovery(self) -> DiscoveryFile | None:
             params["project_id"] = project_id
 
         try:
-            response = requests.get(discovery_url, headers=headers, params=params)
+            response = requests.get(
+                discovery_url,
+                headers=headers,
+                params=params,
+                timeout=REQUEST_TIMEOUT_SECONDS,
+            )
             response.raise_for_status()
         except (
             requests.exceptions.ConnectionError,
@@ -270,17 +276,15 @@ def load_remote_discovery(self) -> DiscoveryFile | None:
 
         return self.load_discovery(remote_discovery, cache=True)
 
-    def load_cached_discovery(self):
+    def load_cached_discovery(self) -> DiscoveryFile | None:
         """Load the cached `discovery.yml` manifest.
 
         Returns:
             The discovery file.
         """
-        try:
+        with suppress(FileNotFoundError):
             with self.cached_discovery_file.open() as cached_discovery:
                 return self.load_discovery(cached_discovery)
-        except FileNotFoundError:
-            pass
 
     def load_bundled_discovery(self):
         """Load the bundled `discovery.yml` manifest.
@@ -436,21 +440,15 @@ def find_related_plugin_refs(
         """
         plugin_types = plugin_types or list(PluginType)
 
-        try:
+        with suppress(ValueError):
             plugin_types.remove(target_plugin.type)
-        except ValueError:
-            pass
 
-        related_plugin_refs = []
-
-        related_plugin_refs.extend(
+        return [
             related_plugin_def
             for plugin_type in plugin_types
             for related_plugin_def in self.get_plugins_of_type(plugin_type)
             if related_plugin_def.namespace == target_plugin.namespace
-        )
-
-        return related_plugin_refs
+        ]
 
 
 class LockedDefinitionService(PluginRepository):


Test patch:
diff --git a/tests/meltano/core/test_plugin_discovery_service.py b/tests/meltano/core/test_plugin_discovery_service.py
--- a/tests/meltano/core/test_plugin_discovery_service.py
+++ b/tests/meltano/core/test_plugin_discovery_service.py
@@ -62,7 +62,10 @@ class TestPluginDiscoveryService:
     @pytest.mark.order(0)
     @pytest.mark.meta
     def test_discovery_url_mock(self, subject):
-        assert requests.get(subject.discovery_url).status_code == HTTP_STATUS_TEAPOT
+        assert (
+            requests.get(subject.discovery_url, timeout=30.0).status_code
+            == HTTP_STATUS_TEAPOT
+        )
 
     @pytest.fixture
     def discovery_yaml(self, subject):