Skip to content

Fix UnicodeDecodeError: 'utf-8' codec can't decode byte

Samuel Debionne requested to merge fix-unicode-error into 4.2.5_patched

Closes https://github.com/Supervisor/supervisor/issues/1485.

Seen on ID10:

Traceback (most recent call last):
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/gevent/pywsgi.py", line 999, in handle_one_response
    self.run_application()
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/gevent/pywsgi.py", line 946, in run_application
    self.process_result()
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/gevent/pywsgi.py", line 930, in process_result
    for data in self.result:
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/werkzeug/wsgi.py", line 462, in __next__
    return self._next()
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/werkzeug/wrappers/response.py", line 50, in _iter_encoded
    for item in iterable:
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/multivisor/server/web.py", line 149, in event_stream
    data = tail(pname, offset, length)
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/zerorpc/core.py", line 278, in <lambda>
    return lambda *args, **kargs: self(method, *args, **kargs)
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/zerorpc/core.py", line 270, in __call__
    return self._process_response(request_event, bufchan, timeout)
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/zerorpc/core.py", line 238, in _process_response
    reply_event, self._handle_remote_error)
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/zerorpc/patterns.py", line 45, in process_answer
    raise exception
zerorpc.exceptions.RemoteError: Traceback (most recent call last):
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/zerorpc/core.py", line 153, in _async_task
    functor.pattern.process_call(self._context, bufchan, event, functor)
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/zerorpc/patterns.py", line 30, in process_call
    result = functor(*req_event.args)
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/zerorpc/decorators.py", line 44, in __call__
    return self._functor(*args, **kargs)
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/multivisor/rpc.py", line 43, in wrapper
    result = meth(*args, **kwargs)
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/supervisor/rpcinterface.py", line 774, in tailProcessStdoutLog
    return self._tailProcessLog(name, offset, length, 'stdout')
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/supervisor/rpcinterface.py", line 752, in _tailProcessLog
    return tailFile(logfile, int(offset), int(length))
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/supervisor/options.py", line 2139, in tailFile
    return [as_string(data), offset, overflow]
  File "/users/blissadm/conda/miniconda/envs/multivisor/lib/python3.7/site-packages/supervisor/compat.py", line 60, in as_string
    return s.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1970-1972: invalid continuation byte

2024-09-25T11:48:51Z {'REMOTE_ADDR': '172.24.9.75', 'REMOTE_PORT': '62057', 'HTTP_HOST': 'tina.esrf.fr:22000', (hidden keys: 26)} failed with RemoteError

172.24.9.75 - - [2024-09-25 13:48:51] "GET /api/process/log/out/tail/lid10bas1:XBPM:xbpm-mbeam HTTP/1.1" 500 161 0.006918

Merge request reports

Loading