浏览代码

[beeswax] Do not error on invalid session in request

If the frontend sends a request with session that is no longer in the
db or malformed, the current `Session.object.get()` throws an error.
The change to using `filter().first()` would get the session if found
in db or `None` rather than throwing an exception. This would let the
query proceed with a new session getting created.
Amit Srivastava 4 月之前
父节点
当前提交
fdf2be6ebe
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

+ 1 - 1
desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

@@ -705,7 +705,7 @@ DROP TABLE IF EXISTS `%(table)s`;
         filters = {'id': session_id, 'application': 'beeswax' if type == 'hive' or type == 'llap' else type}
         if not is_admin(self.user):
           filters['owner'] = self.user
-        return Session.objects.get(**filters)
+        return Session.objects.filter(**filters).first()
 
   def _get_hive_execution_engine(self, notebook, snippet):
     # Get hive.execution.engine from snippet properties, if none, then get from session