Skip to content

Commit a21bf04

Browse files
authored
Merge pull request #98 from maxmind/greg/release
2.7.0
2 parents 004fb68 + 9cab064 commit a21bf04

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

HISTORY.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@
33
History
44
-------
55

6-
2.7.0
6+
2.7.2 (2022-03-29)
7+
++++++++++++++++++
8+
9+
* Updated code to correctly handle ``None`` ``Content-Type`` from minFraud
10+
web service. This should never happen, but if it does, the correct
11+
exception will now be thrown.
12+
13+
2.7.1 (2022-03-29)
14+
++++++++++++++++++
15+
16+
* Fixed ``KeyError`` when using the ``report()`` method. Reported by siang.
17+
GitHub #99.
18+
19+
2.7.0 (2022-03-28)
720
++++++++++++++++++
821

922
* Added the input ``/credit_card/country``. This is the country where the

minfraud/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Internal module for version (to prevent cyclic imports)"""
2-
__version__ = "2.6.0"
2+
__version__ = "2.7.2"

minfraud/webservice.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def _handle_success(
8383
return model_class(decoded_body) # type: ignore
8484

8585
def _exception_for_error(
86-
self, status: int, content_type: str, raw_body: str, uri: str
86+
self, status: int, content_type: Optional[str], raw_body: str, uri: str
8787
) -> Union[
8888
AuthenticationError,
8989
InsufficientFundsError,
@@ -100,7 +100,7 @@ def _exception_for_error(
100100
return self._exception_for_unexpected_status(status, raw_body, uri)
101101

102102
def _exception_for_4xx_status(
103-
self, status: int, content_type: str, raw_body: str, uri: str
103+
self, status: int, content_type: Optional[str], raw_body: str, uri: str
104104
) -> Union[
105105
AuthenticationError,
106106
InsufficientFundsError,
@@ -113,7 +113,7 @@ def _exception_for_4xx_status(
113113
return HTTPError(
114114
f"Received a {status} error with no body", status, uri, raw_body
115115
)
116-
if content_type.find("json") == -1:
116+
if content_type is None or content_type.find("json") == -1:
117117
return HTTPError(
118118
f"Received a {status} with the following body: {raw_body}",
119119
status,
@@ -618,7 +618,7 @@ def report(self, report: Dict[str, Optional[str]], validate: bool = True) -> Non
618618

619619
response = self._do_request(uri, prepared_request)
620620
status = response.status_code
621-
content_type = response.headers["Content-Type"]
621+
content_type = response.headers.get("Content-Type")
622622
raw_body = response.text
623623
if status != 204:
624624
raise self._exception_for_error(status, content_type, raw_body, uri)
@@ -636,7 +636,7 @@ def _response_for(
636636

637637
response = self._do_request(uri, prepared_request)
638638
status = response.status_code
639-
content_type = response.headers["Content-Type"]
639+
content_type = response.headers.get("Content-Type")
640640
raw_body = response.text
641641
if status != 200:
642642
raise self._exception_for_error(status, content_type, raw_body, uri)

0 commit comments

Comments
 (0)