You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/05/13 22:15:58 UTC

[GitHub] [beam] TheNeuralBit commented on a change in pull request #11696: [BEAM-9975] Log invalid dictionary after unsuccessful struct conversion.

TheNeuralBit commented on a change in pull request #11696:
URL: https://github.com/apache/beam/pull/11696#discussion_r424762163



##########
File path: sdks/python/apache_beam/runners/job/utils.py
##########
@@ -23,14 +23,19 @@
 from __future__ import absolute_import
 
 import json
+import logging
 
 from google.protobuf import json_format
 from google.protobuf import struct_pb2
 
 
 def dict_to_struct(dict_obj):
   # type: (dict) -> struct_pb2.Struct
-  return json_format.ParseDict(dict_obj, struct_pb2.Struct())
+  try:
+    return json_format.ParseDict(dict_obj, struct_pb2.Struct())
+  except json_format.ParseError:
+    logging.error('Failed to parse dict {0}'.format(dict_obj))

Review comment:
       lint error:
   ```
   apache_beam/runners/job/utils.py:37:18: W1202: Use % formatting in logging functions and pass the % parameters as arguments (logging-format-interpolation)
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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