graphite-project / carbon

Carbon is one of the components of Graphite, and is responsible for receiving metrics over the network and writing them down to disk using a storage backend.
http://graphite.readthedocs.org/
Apache License 2.0
1.5k stars 490 forks source link

[BUG] Unicode decode error not caught? #941

Closed chakflying closed 1 year ago

chakflying commented 1 year ago

Please report bug only for carbon component here, if you want to to do so for Graphite, please use graphite-web repo

Describe the bug Looks like the server crashed when unicode decode error occurs.

2023-01-29T02:20:47.647 app[357a1dae] hkg [info] 29/01/2023 02:20:47 :: [console] Unhandled Error
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] Traceback (most recent call last):
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] File "/opt/graphite/lib/python3.9/site-packages/twisted/python/log.py", line 96, in callWithLogger
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] return callWithContext({"system": lp}, func, *args, **kw)
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] File "/opt/graphite/lib/python3.9/site-packages/twisted/python/log.py", line 80, in callWithContext
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] return context.call({ILogContext: newCtx}, func, *args, **kw)
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] File "/opt/graphite/lib/python3.9/site-packages/twisted/python/context.py", line 117, in callWithContext
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] return self.currentContext().callWithContext(ctx, func, *args, **kw)
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] File "/opt/graphite/lib/python3.9/site-packages/twisted/python/context.py", line 82, in callWithContext
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] return func(*args, **kw)
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] --- <exception caught here> ---
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] File "/opt/graphite/lib/python3.9/site-packages/twisted/internet/posixbase.py", line 487, in _doReadOrWrite
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] why = selectable.doRead()
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] File "/opt/graphite/lib/python3.9/site-packages/twisted/internet/tcp.py", line 248, in doRead
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] return self._dataReceived(data)
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] File "/opt/graphite/lib/python3.9/site-packages/twisted/internet/tcp.py", line 253, in _dataReceived
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] rval = self.protocol.dataReceived(data)
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] File "/opt/graphite/lib/python3.9/site-packages/twisted/protocols/basic.py", line 440, in dataReceived
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] self.lineReceived(line)
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] File "/opt/graphite/lib/carbon/protocols.py", line 193, in lineReceived
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] line = line.decode('utf-8')
2023-01-29T02:20:47.647 app[357a1dae] hkg [info] builtins.UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 5: invalid continuation byte 

To Reproduce Not sure, but possibly sending invalid unicode bytes to the plaintext metrics endpoint.

Expected behavior Exception should be caught.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.