From f614d68c4107a6eb6afde507bdbcefec9edd3b05 Mon Sep 17 00:00:00 2001 From: Christopher Hart Date: Fri, 19 Dec 2025 16:53:36 -0500 Subject: [PATCH] Format semantic validation errors as human-readable bulleted list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes error output from inline Python list format: ERROR - Semantic error, rule 101: ... (["error1", "error2"]) To a cleaner bulleted list format: ERROR - Semantic error, rule 101: ...: - error1 - error2 This improves readability when multiple validation errors are reported. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- nac_validate/validator.py | 6 +++--- tests/integration/test_integration.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/nac_validate/validator.py b/nac_validate/validator.py index 4bac414..b15f8ba 100644 --- a/nac_validate/validator.py +++ b/nac_validate/validator.py @@ -176,9 +176,9 @@ def validate_semantics(self, input_paths: list[Path]) -> None: if len(results) > 0: for id, paths in results.items(): - msg = ( - f"Semantic error, rule {id}: {self.rules[id].description} ({paths})" - ) + header = f"Semantic error, rule {id}: {self.rules[id].description}:" + items = "\n".join(f" - {path}" for path in paths) + msg = f"{header}\n{items}" logger.error(msg) semantic_errors.append(msg) diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index 6f37859..d1b03a2 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -225,3 +225,22 @@ def test_merge(tmpdir: Path) -> None: ) assert result.exit_code == 0 assert filecmp.cmp(output_path, result_path, shallow=False) + + +def test_semantic_error_output_format() -> None: + """Test that semantic errors are formatted as a human-readable bulleted list.""" + runner = CliRunner() + input_path = "tests/integration/fixtures/data_semantic_error/" + rules_path = "tests/integration/fixtures/rules/" + result = runner.invoke( + nac_validate.cli.main.app, + ["-r", rules_path, "-v", "ERROR", input_path], + ) + assert result.exit_code == 1 + # Verify bulleted list format with 4-space indent + assert " - " in result.output + # Verify header ends with colon (not parentheses with list) + assert "Semantic error, rule 101:" in result.output + # Verify no Python list representation in output + assert '["' not in result.output + assert "']" not in result.output