This is an automated email from the ASF dual-hosted git repository.

japetrsn pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-kafka.git


The following commit(s) were added to refs/heads/master by this push:
     new 35771de  Do not fire trigger with invalid JSON (#319)
35771de is described below

commit 35771decd0fc01e11613862fca02eacd1b10f632
Author: James Dubee <[email protected]>
AuthorDate: Thu Feb 21 12:48:08 2019 -0500

    Do not fire trigger with invalid JSON (#319)
    
    * Do not fire trigger with JSON constants
    
    * Update parameter list
---
 provider/consumer.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/provider/consumer.py b/provider/consumer.py
index 84e1e2d..d4863ce 100644
--- a/provider/consumer.py
+++ b/provider/consumer.py
@@ -485,7 +485,7 @@ class ConsumerProcess (Process):
 
         if self.encodeValueAsJSON:
             try:
-                parsed = json.loads(value)
+                parsed = json.loads(value, 
parse_constant=self.__errorOnJSONConstant)
                 logging.debug('[{}] Successfully encoded a message as 
JSON.'.format(self.trigger))
                 return parsed
             except ValueError:
@@ -523,3 +523,6 @@ class ConsumerProcess (Process):
 
     def __on_revoke(self, consumer, partitions):
         logging.info('[{}] Partition assignment has been revoked. Disconnected 
from broker(s)'.format(self.trigger))
+
+    def __errorOnJSONConstant(self, data):
+       raise(ValueError('Invalid JSON detected.'))

Reply via email to