Fix name not escaped as regex (all services "get_all" use regex for name)

This commit is contained in:
allegroai 2022-09-02 23:43:42 +03:00
parent 3f1ce847dc
commit 1bf865ec08

View File

@ -347,7 +347,7 @@ class ServiceCommandSection(BaseCommandSection):
except AttributeError: except AttributeError:
raise NameResolutionError('Name resolution unavailable for {}'.format(service)) raise NameResolutionError('Name resolution unavailable for {}'.format(service))
request = request_cls.from_dict(dict(name=name, only_fields=['name', 'id'])) request = request_cls.from_dict(dict(name=re.escape(name), only_fields=['name', 'id']))
# from_dict will ignore unrecognised keyword arguments - not all GetAll's have only_fields # from_dict will ignore unrecognised keyword arguments - not all GetAll's have only_fields
response = getattr(self._session.send_api(request), service) response = getattr(self._session.send_api(request), service)
matches = [db_object for db_object in response if name.lower() == db_object.name.lower()] matches = [db_object for db_object in response if name.lower() == db_object.name.lower()]