Skip to content

Commit 89d7f54

Browse files
authored
Handle the case when query runner configuration is an empty dict. (#7258)
1 parent d884da2 commit 89d7f54

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

redash/query_runner/elasticsearch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(self, configuration):
9191

9292
logger.setLevel(logging.DEBUG)
9393

94-
self.server_url = self.configuration["server"]
94+
self.server_url = self.configuration.get("server", "")
9595
if self.server_url[-1] == "/":
9696
self.server_url = self.server_url[:-1]
9797

redash/query_runner/mongodb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def __init__(self, configuration):
188188

189189
self.syntax = "json"
190190

191-
self.db_name = self.configuration["dbName"]
191+
self.db_name = self.configuration.get("dbName", "")
192192

193193
self.is_replica_set = (
194194
True if "replicaSetName" in self.configuration and self.configuration["replicaSetName"] else False

redash/query_runner/script.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ def type(cls):
5555
def __init__(self, configuration):
5656
super(Script, self).__init__(configuration)
5757

58+
path = self.configuration.get("path", "")
5859
# If path is * allow any execution path
59-
if self.configuration["path"] == "*":
60+
if path == "*":
6061
return
6162

6263
# Poor man's protection against running scripts from outside the scripts directory
63-
if self.configuration["path"].find("../") > -1:
64+
if path.find("../") > -1:
6465
raise ValueError("Scripts can only be run from the configured scripts directory")
6566

6667
def test_connection(self):

redash/query_runner/sqlite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def type(cls):
2828
def __init__(self, configuration):
2929
super(Sqlite, self).__init__(configuration)
3030

31-
self._dbpath = self.configuration["dbpath"]
31+
self._dbpath = self.configuration.get("dbpath", "")
3232

3333
def _get_tables(self, schema):
3434
query_table = "select tbl_name from sqlite_master where type='table'"

0 commit comments

Comments
 (0)