Skip to content

Commit

Permalink
Validate full model name in the deprecate model flow (#427)
Browse files Browse the repository at this point in the history
Earlier, the model name was not being validated for the deprecate model
action. It was getting validated for all other actions including the
unassign and deregister actions (which are variations of the deprecate
action).

Resolves
iterative/dvc#9821 (comment)
  • Loading branch information
tapadipti authored Oct 26, 2023
1 parent 9039e87 commit 96c6d9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gto/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def assert_name_is_valid(value):
if not check_string_is_valid(value, regex=name_re):
raise ValidationError(
f"Invalid value '{value}'. Only letters, numbers, '_', '-', '/' are allowed."
"Value must be of len >= 2 and must start and end with a letter or a number."
" Value must be of len >= 2 and must start and end with a letter or a number."
)


Expand All @@ -81,7 +81,7 @@ def assert_fullname_is_valid(value):
# fix error message to be regex-specific
raise ValidationError(
f"Invalid value '{value}'. Only letters, numbers, '_', '-', '/' are allowed."
"Value must be of len >= 2 and must start and end with a letter or a number."
" Value must be of len >= 2 and must start and end with a letter or a number."
)


Expand Down
2 changes: 2 additions & 0 deletions gto/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ def deprecate(
author: Optional[str] = None,
author_email: Optional[str] = None,
) -> Optional[Deprecation]:
"""Deprecate artifact"""
assert_fullname_is_valid(name)
if force:
if simple:
raise WrongArgs("Can't use 'force' with 'simple=True'")
Expand Down

0 comments on commit 96c6d9d

Please sign in to comment.