diff --git a/plugins/action/cloudflare_records_converged.py b/plugins/action/cloudflare_records_converged.py index 6e24436f37..d16c6b6625 100644 --- a/plugins/action/cloudflare_records_converged.py +++ b/plugins/action/cloudflare_records_converged.py @@ -360,9 +360,11 @@ def split( zone already holds as declared, and one warning per zone whose records could not be read, whose entries all stay pending. Every entry of a record set declared more than once stays pending when - one of its entries is hazardous or two of them declare the record - the module finds by one ``_identity`` differently, since each - verdict alone would let the last entry's apply undo the other's. + one of its entries is hazardous, ``expected`` cannot judge one of + them, whose apply may still write the record set, or two of them + declare the record the module finds by one ``_identity`` differently, + since each verdict alone would let the last entry's apply undo the + other's. """ owners = [_owner(record) for record in records] wants = [expected(record) for record in records] @@ -372,9 +374,10 @@ def split( for owner, record, want in zip(owners, records, wants, strict=True): if owner is None or sizes[owner] < 2: continue - if _hazardous(record) or ( - want is not None - and declared.setdefault((owner, _identity(want)), want) != want + if ( + want is None + or _hazardous(record) + or declared.setdefault((owner, _identity(want)), want) != want ): blocked.add(owner) zones: dict[str, list[Any] | None] = {} diff --git a/tests/unit/python/plugins/action/test_cloudflare_records_converged.py b/tests/unit/python/plugins/action/test_cloudflare_records_converged.py index 9cf64cfaf3..8f4b4eb991 100644 --- a/tests/unit/python/plugins/action/test_cloudflare_records_converged.py +++ b/tests/unit/python/plugins/action/test_cloudflare_records_converged.py @@ -471,6 +471,29 @@ class TestCloudflareRecordsConverged(unittest.TestCase): self.assertEqual(pending, records) self.assertEqual(labels, []) + def test_a_name_with_an_entry_the_plugin_cannot_judge_stays_pending(self): + t = f"t.{ZONE}" + txt = {"type": "TXT", "zone": ZONE, "name": "t"} + groups = { + "txt int value": ( + [dict(txt, value=12345), dict(txt, value="12345", ttl=300)], + [rr("TXT", t, "12345", ttl=300)], + ), + "txt int value last": ( + [dict(txt, value="12345", ttl=300), dict(txt, value=12345)], + [rr("TXT", t, "12345", ttl=300)], + ), + "a null ttl": ( + [a("x", ttl=None), a("x", ttl=300)], + [rr("A", f"x.{ZONE}", "203.0.113.7", ttl=300)], + ), + } + for group, (records, zone) in groups.items(): + with self.subTest(group=group): + pending, labels, _ = run_split(records, _FakeCloudflare([zone])) + self.assertEqual(pending, records) + self.assertEqual(labels, []) + def test_entries_of_one_name_the_module_edits_as_distinct_or_equal_records_stay_judged( self, ):