Skip to content

Commit

Permalink
Metadata API: fix Key validation exception
Browse files Browse the repository at this point in the history
In pr theupdateframework#1449 we introduced
Key validation and there decided to raise "ValueError" if one of
keyid, scheme, keyval or keytype is not a string.
That seems like a mistake given that in the python docs it's written:
"Passing arguments of the wrong type
(e.g. passing a list when an int is expected) should result
in a TypeError, but passing arguments with the wrong value
(e.g. a number outside expected boundaries) should result
in a ValueError."

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
  • Loading branch information
MVrachev committed Jun 22, 2021
1 parent 4fa408a commit b0430e1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tuf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def __init__(
) -> None:
val = keyval["public"]
if not all(isinstance(at, str) for at in [keyid, keytype, scheme, val]):
raise ValueError("Unexpected Key attributes types!")
raise TypeError("Unexpected Key attributes types!")
self.keyid = keyid
self.keytype = keytype
self.scheme = scheme
Expand Down

0 comments on commit b0430e1

Please sign in to comment.