Browse Source

PR448 [notebook] Catch missing 'snippets' field in document2 data in hive_server2_lib

https://github.com/cloudera/hue/pull/448
antbell 9 years ago
parent
commit
140d307c86
1 changed files with 6 additions and 1 deletions
  1. 6 1
      apps/beeswax/src/beeswax/server/hive_server2_lib.py

+ 6 - 1
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -654,7 +654,12 @@ class HiveServerClient:
 
         # Only check last 40 documents for performance
         for doc in docs[:40]:
-          snippet_data = json.loads(doc.data)['snippets'][0]
+          try:
+            snippet_data = json.loads(doc.data)['snippets'][0]
+          except (KeyError, IndexError):
+            # data might not contain a 'snippets' field or it might be empty
+            LOG.warn('No snippets in Document2 object of type query-hive')
+            continue
           session_guid = snippet_data.get('result', {}).get('handle', {}).get('session_guid')
           status = snippet_data.get('status')