Skip to content

Commit

Permalink
FIX: Catch cases where server may be incorrectly configured (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgxd authored Aug 15, 2022
1 parent 6f25f25 commit 93d59d0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions migas/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import sys
import typing
from http.client import HTTPResponse

from migas.config import Config, logger, telemetry_enabled
from migas.request import request
Expand Down Expand Up @@ -162,11 +161,12 @@ def _formulate_query(params: dict, template: OperationTemplate) -> str:
return query


def _filter_response(response: HTTPResponse, operation: str, fallback: dict):
res = response.get("data")
# success
if isinstance(res, dict):
return res.get(operation, fallback)
def _filter_response(response: typing.Union[dict, str], operation: str, fallback: dict):
if isinstance(response, dict):
res = response.get("data")
# success
if isinstance(res, dict):
return res.get(operation, fallback)

# Otherwise data is None, return fallback response with error reported
try:
Expand Down

0 comments on commit 93d59d0

Please sign in to comment.