Skip to content

Commit

Permalink
Fail if key is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-feld committed Aug 27, 2019
1 parent 938a0b3 commit ae4f570
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __new__(cls, value: str) -> "EntryKey":

@staticmethod
def create(value: str) -> "EntryKey":
if len(value) > 255 or any(c not in PRINTABLE for c in value):
if not 0 < len(value) <= 255 or any(c not in PRINTABLE for c in value):
raise ValueError("Invalid EntryKey", value)

return typing.cast(EntryKey, value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def test_entry_ttl_unlimited_propagation(self):


class TestEntryKey(unittest.TestCase):
def test_create_empty(self):
with self.assertRaises(ValueError):
distributedcontext.EntryKey.create("")

def test_create_too_long(self):
with self.assertRaises(ValueError):
distributedcontext.EntryKey.create("a" * 256)
Expand Down

0 comments on commit ae4f570

Please sign in to comment.