From e45b90e64eb334b85c254cc92f306dca3f53fa6f Mon Sep 17 00:00:00 2001 From: Diego Bonato Date: Tue, 17 Mar 2026 11:52:34 +0100 Subject: [PATCH] Handle OSError when validating registered project paths on startup When a registered project path points to a stale or unreachable filesystem (e.g. a disconnected SSHFS mount), `path.exists()` raises `OSError: [Errno 5] Input/output error` instead of returning False. This uncaught exception crashes the entire MCP server on startup, making all Serena tools unavailable. Wrap the `path.exists()` call in a try/except OSError so that inaccessible paths are gracefully skipped with a warning, matching the existing behavior for non-existent paths. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/serena/config/serena_config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/serena/config/serena_config.py b/src/serena/config/serena_config.py index b996ad95..e863308d 100644 --- a/src/serena/config/serena_config.py +++ b/src/serena/config/serena_config.py @@ -826,7 +826,12 @@ class SerenaConfig(SharedConfig): instance.projects = [] for path in loaded_commented_yaml["projects"]: path = Path(path).resolve() - if not path.exists() or (path.is_dir() and not os.path.isfile(instance.get_project_yml_location(str(path)))): + try: + path_exists = path.exists() + except OSError as e: + log.warning(f"Project path {path} is not accessible ({e}), skipping.") + continue + if not path_exists or (path.is_dir() and not os.path.isfile(instance.get_project_yml_location(str(path)))): log.warning(f"Project path {path} does not exist or no associated project configuration file found, skipping.") continue if path.is_file():