Skip to content

Commit 6dc926c

Browse files
committed
Add validation rule for empty sized containers
As it seems, GitHub passes unset values as empty strings, meaning that they pass validation for the string type. To prevent empty strings from making it past the verification feature, I've now added size validation for whenever a value is a subclass of `collections.abc.Sized`.
1 parent 870e597 commit 6dc926c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

github_status_embed/types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import collections
34
import dataclasses
45
import enum
56
import json
@@ -71,6 +72,8 @@ def from_arguments(cls, arguments: typing.Dict[str, str]) -> typing.Optional[Typ
7172
value = _type[value.upper()]
7273
else:
7374
value = _type(value)
75+
if isinstance(value, collections.Sized) and len(value) == 0:
76+
raise ValueError
7477
except (ValueError, KeyError):
7578
raise InvalidArgument(f"invalid value for `{attribute}`: {value}") from None
7679
else:

0 commit comments

Comments
 (0)