Skip to content

Commit 6c1b7e0

Browse files
fix: handle empty 2xx responses (#40)
* fix: handle empty 2xx responses gracefully Co-Authored-By: [email protected] <[email protected]> * chore: prepare for 0.5.14 release --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]>
1 parent 8d7aae7 commit 6c1b7e0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

knockapi/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.5.13'
1+
__version__ = '0.5.14'

knockapi/client.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ def request(self, method, endpoint, payload=None, options={}):
3030
timeout=self.timeout,
3131
)
3232

33-
# If we got a successful response, then attempt to deserialize as JSON
33+
# If we got a successful response, check for content before attempting to deserialize as JSON
3434
if r.ok:
35-
try:
36-
return r.json()
37-
except JSONDecodeError:
38-
return None
35+
if r.content and len(r.content) > 0:
36+
try:
37+
return r.json()
38+
except JSONDecodeError:
39+
return None
40+
return None
3941

4042
return r.raise_for_status()
4143

0 commit comments

Comments
 (0)