fix kafka decoding error blocking consumption#390
Merged
mirceaulinic merged 1 commit intonapalm-automation:developfrom Feb 9, 2026
Merged
Conversation
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.
mirceaulinic
approved these changes
Feb 9, 2026
Member
mirceaulinic
left a comment
There was a problem hiding this comment.
Odd. The tests aren't passing, but many things are broken here, this repo needs some love and I'll make some time soon for a refresh & release. Thanks for your contribution @matthieugouel!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For some reason we received a non utf-8 message from Kafka topic, and the application is getting stuck with this error:
This fix try catch on the initial key decoding and return and follow the same error handling pattern as the message json decoding below.