Skip to content

Commit e9ecb59

Browse files
authored
Raise exception when empty key passed to fetchItem* (#432)
1 parent cbdf5ec commit e9ecb59

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

plexapi/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ def fetchItem(self, ekey, cls=None, **kwargs):
132132
* __regex: Value matches the specified regular expression.
133133
* __startswith: Value starts with specified arg.
134134
"""
135+
if ekey is None:
136+
raise BadRequest('ekey was not provided')
135137
if isinstance(ekey, int):
136138
ekey = '/library/metadata/%s' % ekey
137139
for elem in self._server.query(ekey):
@@ -145,6 +147,8 @@ def fetchItems(self, ekey, cls=None, **kwargs):
145147
and attrs. See :func:`~plexapi.base.PlexObject.fetchItem` for more details
146148
on how this is used.
147149
"""
150+
if ekey is None:
151+
raise BadRequest('ekey was not provided')
148152
data = self._server.query(ekey)
149153
items = self.findItems(data, cls, ekey, **kwargs)
150154
librarySectionID = data.attrib.get('librarySectionID')

0 commit comments

Comments
 (0)