Skip to content

UnicodeDecodeError: 'ascii' codec can't decode byte #392

@ShiftyMcCool

Description

@ShiftyMcCool

Hello,

I've searched for this error and have found several closed issues for this error, but I am getting the following error:

Traceback (most recent call last):
  File "/webroot/common-content/new_lambda_function.py", line 52, in lambda_handler
    index_response = es.index(index="resources", doc_type="resource", id=resource['content']['id'], body=resource['content'])
  File "/webroot/common-content/venv/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/webroot/common-content/venv/local/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 279, in index
    _make_path(index, doc_type, id), params=params, body=body)
  File "/webroot/common-content/venv/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 329, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/webroot/common-content/venv/local/lib/python2.7/site-packages/elasticsearch/connection/http_requests.py", line 68, in perform_request
    response = self.session.request(method, url, data=body, timeout=timeout or self.timeout)
  File "/webroot/common-content/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/webroot/common-content/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/webroot/common-content/venv/local/lib/python2.7/site-packages/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/webroot/common-content/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 559, in urlopen
    body=body, headers=headers)
  File "/webroot/common-content/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 353, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python2.7/httplib.py", line 979, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1013, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 975, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 833, in _send_output
    msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 568: ordinal not in range(128)

It seems that a previously posted workaround has been implemented (#374). This issue report is my problem exactly, is there any solution to this with Python 2.7? There is no chance of converting to Python 3 since AWS Lambda does not support it.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions