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) <noreply@anthropic.com>
This commit is contained in:
Diego BonatoandClaude Opus 4.6 committed 2026-03-17 11:52:34 +01:00
1 parent 6a16b5b9e9
commit e45b90e64e
1 file changed
+6 -1
+6 -1
View File
@@ -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():