You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/07 18:40:14 UTC
[GitHub] dubeejw commented on a change in pull request #247: Fix uncaught exception occurring when reading in a message containing non-unicode bytes
dubeejw commented on a change in pull request #247: Fix uncaught exception occurring when reading in a message containing non-unicode bytes
URL: https://github.com/apache/incubator-openwhisk-package-kafka/pull/247#discussion_r166713009
##########
File path: provider/consumer.py
##########
@@ -446,6 +446,13 @@ def __getOffsetList(self, messages):
return offsets
def __encodeMessageIfNeeded(self, value):
+ # let's make sure whatever data we're getting is utf-8 encoded
+ try:
+ value = value.encode('utf-8')
+ except UnicodeDecodeError:
+ logging.warn('[{}] Value contains non-unicode bytes. Replacing invalid bytes.'.format(self.trigger))
+ value = unicode(value, errors='replace').encode('utf-8')
Review comment:
May want to doc this behavior in the future.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services