Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metaflow/plugins/aws/aws_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def validate_aws_tag(key: str, value: str):

if not re.match(PERMITTED, key):
raise MetaflowException(
"Key *s* is not permitted. Tags must match pattern: %s" % (key, PERMITTED)
"Key *%s* is not permitted. Tags must match pattern: %s" % (key, PERMITTED)
)
if not re.match(PERMITTED, value):
raise MetaflowException(
Expand Down
15 changes: 15 additions & 0 deletions test/unit/test_aws_util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from metaflow.exception import MetaflowException
from metaflow.plugins.aws.aws_utils import validate_aws_tag


Expand Down Expand Up @@ -37,3 +38,17 @@ def test_validate_aws_tag(key, value, should_raise):
did_raise = True

assert did_raise == should_raise


@pytest.mark.parametrize(
"key, value, expected_prefix",
[
("#not-permitted", "ok", "Key *#not-permitted* is not permitted."),
("ok", "#not-permitted", "Value *#not-permitted* is not permitted."),
],
)
def test_validate_aws_tag_not_permitted_message(key, value, expected_prefix):
with pytest.raises(MetaflowException) as exc_info:
validate_aws_tag(key, value)

assert str(exc_info.value).startswith(expected_prefix)