Skip to content

Commit

Permalink
chore: handle json values
Browse files Browse the repository at this point in the history
  • Loading branch information
rajesh-jonnalagadda committed Dec 10, 2024
1 parent 9eef346 commit 481f810
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion keep/providers/http_provider/http_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ def _query(
if headers is None:
headers = {}
if isinstance(headers, str):
headers = json.loads(headers)
headers = json.loads(headers) if len(headers) > 0 else {}
if body is None:
body = {}
if isinstance(body, str):
body = json.loads(body) if len(body) > 0 else {}
if params is None:
params = {}
if isinstance(params, str):
params = json.loads(params) if len(params) > 0 else {}

# todo: this might be problematic if params/body/headers contain sensitive data
# think about changing those debug messages or adding a flag to enable/disable them
Expand Down
6 changes: 5 additions & 1 deletion keep/providers/webhook_provider/webhook_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,15 @@ def _query(
if headers is None:
headers = {}
if isinstance(headers, str):
headers = json.loads(headers)
headers = json.loads(headers) if len(headers) > 0 else {}
if body is None:
body = {}
if isinstance(body, str):
body = json.loads(body) if len(body) > 0 else {}
if params is None:
params = {}
if isinstance(params, str):
params = json.loads(params) if len(params) > 0 else {}

if http_basic_authentication_username and http_basic_authentication_password:
credentials = f"{http_basic_authentication_username}:{http_basic_authentication_password}"
Expand Down

0 comments on commit 481f810

Please sign in to comment.