Commit 0a538469 authored by Konstantinos Togias's avatar Konstantinos Togias
Browse files

Reject non-mapping bootstrap files instead of an empty fallback

parent d35aa810
Loading
Loading
Loading
Loading
+2 −1
Changes for src/openop_tfsdk/contract/topology.py: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -81,7 +81,8 @@ class BootstrapTopology(TopologyDiscoveryAdapter):
    @classmethod
    def from_file(cls, path: str) -> "BootstrapTopology":
        with open(path, encoding="utf-8") as handle:
            return cls(yaml.safe_load(handle) or {})
            declaration = yaml.safe_load(handle)
            return cls({} if declaration is None else declaration)

    def get_control_path_configurations(self) -> List[dict]:
        """Runtime-only construction entries from this loaded revision.
+8 −0
Changes for tests/contract/test_bootstrap_runtime_configuration.py: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -128,3 +128,11 @@ def test_binding_cannot_name_an_undeclared_control_path():
def test_malformed_control_path_configuration_is_a_typed_error(entries):
    with pytest.raises(ValidationError):
        BootstrapTopology({"control_paths": entries})


@pytest.mark.parametrize("content", ["[]", "false", "0"])
def test_non_mapping_file_cannot_silently_become_an_empty_catalog(tmp_path, content):
    path = tmp_path / "bootstrap.yaml"
    path.write_text(content)
    with pytest.raises(ValidationError, match="mapping"):
        BootstrapTopology.from_file(str(path))