Skip to content

Commit ef8623e

Browse files
committed
work in review suggestions
1 parent f5ada2a commit ef8623e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

localstack-core/localstack/services/sns/v2/provider.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def create_topic(
5858
if not attrs.get(k) or not attrs.get(k) == v:
5959
# TODO:
6060
raise InvalidParameterException("Fix this Exception message and type")
61-
tag_resource_success = extract_tags(topic_arn, tags, True, store)
61+
tag_resource_success = _check_matching_tags(topic_arn, tags, store)
6262
if not tag_resource_success:
6363
raise InvalidParameterException(
6464
"Invalid parameter: Tags Reason: Topic already exists with different tags"
@@ -253,10 +253,14 @@ def _create_default_topic_policy(topic: Topic, context: RequestContext) -> str:
253253
)
254254

255255

256-
# TODO: move this to utils after rebase
257-
def extract_tags(
258-
topic_arn: str, tags: TagList, is_create_topic_request: bool, store: SnsStore
259-
) -> bool:
256+
def _check_matching_tags(topic_arn: str, tags: TagList | None, store: SnsStore) -> bool:
257+
"""
258+
Checks if a topic to be created doesn't already exist with different tags
259+
:param topic_arn: Arn of the topic
260+
:param tags: Tags to be checked
261+
:param store: Store object that holds the topics and tags
262+
:return: False if there is a mismatch in tags, True otherwise
263+
"""
260264
existing_tags = store.TAGS.list_tags_for_resource(topic_arn)["Tags"]
261265
# if this is none there is nothing to check
262266
if topic_arn in store.topics:
@@ -265,6 +269,6 @@ def extract_tags(
265269
for tag in tags:
266270
# this means topic already created with empty tags and when we try to create it
267271
# again with other tag value then it should fail according to aws documentation.
268-
if is_create_topic_request and existing_tags is not None and tag not in existing_tags:
272+
if existing_tags is not None and tag not in existing_tags:
269273
return False
270274
return True

0 commit comments

Comments
 (0)