Skip to content

Commit

Permalink
Handle the case when query runner configuration is an empty dict.
Browse files Browse the repository at this point in the history
  • Loading branch information
arikfr committed Dec 20, 2024
1 parent d884da2 commit ae17b43
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion redash/query_runner/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, configuration):

logger.setLevel(logging.DEBUG)

self.server_url = self.configuration["server"]
self.server_url = self.configuration.get("server", "")
if self.server_url[-1] == "/":
self.server_url = self.server_url[:-1]

Expand Down
2 changes: 1 addition & 1 deletion redash/query_runner/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def __init__(self, configuration):

self.syntax = "json"

self.db_name = self.configuration["dbName"]
self.db_name = self.configuration.get("dbName", "")

self.is_replica_set = (
True if "replicaSetName" in self.configuration and self.configuration["replicaSetName"] else False
Expand Down
5 changes: 3 additions & 2 deletions redash/query_runner/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ def type(cls):
def __init__(self, configuration):
super(Script, self).__init__(configuration)

path = self.configuration.get("path", "")
# If path is * allow any execution path
if self.configuration["path"] == "*":
if path == "*":
return

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

def test_connection(self):
Expand Down
2 changes: 1 addition & 1 deletion redash/query_runner/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def type(cls):
def __init__(self, configuration):
super(Sqlite, self).__init__(configuration)

self._dbpath = self.configuration["dbpath"]
self._dbpath = self.configuration.get("dbpath", "")

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

0 comments on commit ae17b43

Please sign in to comment.