As you can see in Transform.perform_request from the Python elasticsearch client, body can be None. However, using a None body raises a TypeError in ElasticQueryInfo.__init__:
def __init__(self, method, full_url, path, body, status_code, response, duration):
self.method = method
self.full_url = full_url
self.path = path
self.body = _pretty_json(body)
self.status_code = status_code
self.response = _pretty_json(response)
self.duration = round(duration * 1000, 2)
> self.hash = hashlib.md5(self.full_url + self.body).hexdigest()
E TypeError: coercing to Unicode: need string or buffer, NoneType found
Among many options, you can use self.body if self.body else b''. However, do not use bytes(self.body) : it works in Python 2 (yields b'None') but fails with a TypeError in Python 3.
As you can see in Transform.perform_request from the Python elasticsearch client, body can be
None
. However, using aNone
body raises aTypeError
inElasticQueryInfo.__init__
:Among many options, you can use
self.body if self.body else b''
. However, do not usebytes(self.body)
: it works in Python 2 (yieldsb'None'
) but fails with aTypeError
in Python 3.