diff --git a/generic_config_updater/gu_common.py b/generic_config_updater/gu_common.py index 1ef2e42005..b543a1a1b3 100644 --- a/generic_config_updater/gu_common.py +++ b/generic_config_updater/gu_common.py @@ -147,7 +147,13 @@ def validate_config_db_config(self, config_db_as_json): try: tmp_config_db_as_json = copy.deepcopy(config_db_as_json) - sy.loadData(tmp_config_db_as_json) + # Loading data automatically does full validation. + # quiet=True suppresses sonic_yang.loadData's LOG_ERR + # "Data Loading Failed" line on every exception (log-and-throw + # antipattern). Real failures still surface via the returned + # tuple / SonicYangException, so callers retain full error + # signal -- only the duplicate syslog spam is silenced. + sy.loadData(tmp_config_db_as_json, quiet=True) sy.validate_data_tree() diff --git a/tests/generic_config_updater/patch_sorter_test.py b/tests/generic_config_updater/patch_sorter_test.py index baeab6fddb..45bfbbcfc6 100644 --- a/tests/generic_config_updater/patch_sorter_test.py +++ b/tests/generic_config_updater/patch_sorter_test.py @@ -933,6 +933,23 @@ def test_validate__valid_config_db_after_applying_move__success(self): # Act and assert self.assertTrue(validator.validate(self.any_move, self.any_diff)) + def test_validate__passes_quiet_true_to_config_wrapper(self): + # Regression guard: gu_common.ConfigWrapper.validate_config_db_config + # MUST call sonic_yang.loadData with quiet=True so the speculative + # patch-sort search does not spam syslog with transient YANG + # leafref LOG_ERR lines (the sorter already handles those via the + # returned tuple). This is enforced inside ConfigWrapper itself, + # so all callers benefit; FullConfigMoveValidator simply delegates. + config_wrapper = Mock() + config_wrapper.validate_config_db_config.return_value = (True, None) + validator = ps.FullConfigMoveValidator(config_wrapper) + + validator.validate(self.any_move, self.any_diff) + + config_wrapper.validate_config_db_config.assert_called_once_with( + self.any_simulated_config) + + class TestCreateOnlyMoveValidator(unittest.TestCase): def setUp(self): self.validator = ps.CreateOnlyMoveValidator(ps.PathAddressing())