Skip to content

Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.

fix: reject empty nonmapping run configurations (#244)

Rudy Mizrahi Celekli3ddb912069f4
diff --git a/ifixai/cli/config_file.py b/ifixai/cli/config_file.py
index 21694a7..f8a08b7 100644
--- a/ifixai/cli/config_file.py
+++ b/ifixai/cli/config_file.py
@@ -55,7 +55,9 @@ def load_config(start_dir: Path | None = None) -> RunConfig | None:
if not path.exists():
return None
try:
- raw = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
+ raw = yaml.safe_load(path.read_text(encoding="utf-8"))
+ if raw is None:
+ raw = {}
except OSError as exc:
raise ValueError(f"Could not read {CONFIG_FILENAME}: {exc}") from exc
except yaml.YAMLError as exc:
diff --git a/ifixai/tests/test_config_empty_nonmapping.py b/ifixai/tests/test_config_empty_nonmapping.py
new file mode 100644
index 0000000..8f81843
--- /dev/null
+++ b/ifixai/tests/test_config_empty_nonmapping.py
@@ -0,0 +1,18 @@
+from pathlib import Path
+
+import pytest
+
+from ifixai.cli.config_file import load_config
+
+
[email protected]('document', ['[]', 'false', '0', '""'])
+def test_falsey_nonmapping_config_is_rejected(tmp_path: Path, document: str) -> None:
+ (tmp_path / 'ifixai.yaml').write_text(document, encoding='utf-8')
+ with pytest.raises(ValueError, match='mapping'):
+ load_config(tmp_path)
+
+
[email protected]('document', ['', '# empty config', '{}', 'null'])
+def test_empty_config_remains_supported(tmp_path: Path, document: str) -> None:
+ (tmp_path / 'ifixai.yaml').write_text(document, encoding='utf-8')
+ assert load_config(tmp_path) is not None