fix: handle empty projects config key

This commit is contained in:
mehmet turac committed 2026-05-16 01:51:22 +03:00
1 parent 1767a259ce
commit 3ec5485da7
2 files changed
+15 -1

No files matched your search

+1 -1
View File
@@ -871,7 +871,7 @@ class SerenaConfig(SharedConfig, ModeSelectionDefinitionWithBaseModes):
if "projects" not in loaded_commented_yaml:
raise SerenaConfigError("`projects` key not found in Serena configuration. Please update your `serena_config.yml` file.")
instance.projects = []
for path in loaded_commented_yaml["projects"]:
for path in loaded_commented_yaml["projects"] or []:
path = Path(path).resolve()
try:
path_exists = path.exists()
+14
View File
@@ -523,6 +523,20 @@ class TestSerenaConfigFromConfigFileRobustness:
body_lines.append(f" - {p}")
self.master_config_path.write_text("\n".join(body_lines) + "\n")
def test_empty_projects_key_is_treated_as_empty_list(self, monkeypatch):
"""A bare ``projects:`` key should not abort config loading."""
self.master_config_path.write_text("projects:\n")
monkeypatch.setattr(
SerenaConfig,
"_determine_config_file_path",
classmethod(lambda cls: str(self.master_config_path)),
)
config = SerenaConfig.from_config_file(generate_if_missing=False)
assert config.projects == []
def test_malformed_project_is_skipped_with_warning(self, caplog, monkeypatch):
"""A malformed project.yml must not abort loading of the others."""
good_project = self._make_project_dir(