Commit f7dcaa8
committed
fix kafka decoding error blocking consumption
For some reason we received a non utf-8 message from Kafka topic, and the application is getting stuck with this error:
```
Process Process-27:
Traceback (most recent call last):
File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/usr/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3/dist-packages/napalm_logs/listener_proc.py", line 102, in start
log_message, log_source = self.listener.receive()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/napalm_logs/listener/kafka.py", line 83, in receive
log_source = log_source.decode()
^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 1: invalid start byte
```
This fix try catch on the initial key decoding and return and follow the same error handling pattern as the message json decoding below.1 parent 54e7ea5 commit f7dcaa8
1 file changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
81 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
| |||
0 commit comments