From 4adc9c7276fdfbcc5e953b4968f05ca82cd2428e Mon Sep 17 00:00:00 2001 From: Quentin Dawans Date: Fri, 17 Jan 2025 12:48:43 +0100 Subject: [PATCH] Ensure changelog topic configuration doesn't impact data topic configuration --- quixstreams/models/topics/manager.py | 6 ++++-- .../test_models/test_topics/test_manager.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/quixstreams/models/topics/manager.py b/quixstreams/models/topics/manager.py index db039c191..a173cae52 100644 --- a/quixstreams/models/topics/manager.py +++ b/quixstreams/models/topics/manager.py @@ -248,7 +248,8 @@ def topic_config( return TopicConfig( num_partitions=num_partitions or self.default_num_partitions, replication_factor=replication_factor or self.default_replication_factor, - extra_config=extra_config or self.default_extra_config, + # copy the default extra_config to ensure we don't mutate the default + extra_config=extra_config or self.default_extra_config.copy(), ) def topic( @@ -404,7 +405,8 @@ def changelog_topic( config = self.topic_config( num_partitions=source_topic_config.num_partitions, replication_factor=source_topic_config.replication_factor, - extra_config=source_topic_config.extra_config, + # copy the extra_config to ensure we don't mutate the source topic extra config + extra_config=source_topic_config.extra_config.copy(), ) # always override some default configuration diff --git a/tests/test_quixstreams/test_models/test_topics/test_manager.py b/tests/test_quixstreams/test_models/test_topics/test_manager.py index 48794f714..8a4e78bef 100644 --- a/tests/test_quixstreams/test_models/test_topics/test_manager.py +++ b/tests/test_quixstreams/test_models/test_topics/test_manager.py @@ -107,6 +107,8 @@ def test_changelog_topic(self, topic_manager_factory): assert isinstance(getattr(changelog, attr), BytesDeserializer) assert changelog.config.num_partitions == topic.config.num_partitions assert changelog.config.replication_factor == topic.config.replication_factor + + assert topic.config.extra_config.get("cleanup.policy") != "compact" assert changelog.config.extra_config["cleanup.policy"] == "compact" def test_changelog_topic_settings_import(self, topic_manager_factory):