Skip to content

Commit 5922f8c

Browse files
kraju3AaronDDM
andauthored
Validate attachment response and throw error (#396)
* Validate attachment response and throw error * Update nylas/handler/http_client.py Co-authored-by: Aaron de Mello <[email protected]> * Resolve PR comments * Fix pylint warnings * Check the status code before and remove utlity function * Added changelog --------- Co-authored-by: Aaron de Mello <[email protected]>
1 parent b68c893 commit 5922f8c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ nylas-python Changelog
44
Unreleased
55
--------------
66
* Add support for Scheduler APIs
7+
* Fixed attachment download response handling
78

89
v6.4.0
910
----------------

nylas/handler/http_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def _validate_response(response: Response) -> dict:
4545

4646
return json
4747

48-
4948
def _build_query_params(base_url: str, query_params: dict = None) -> str:
5049
query_param_parts = []
5150
for key, value in query_params.items():
@@ -109,7 +108,7 @@ def _execute_download_request(
109108
query_params=None,
110109
stream=False,
111110
overrides=None,
112-
) -> Union[bytes, Response]:
111+
) -> Union[bytes, Response,dict]:
113112
request = self._build_request("GET", path, headers, query_params, overrides)
114113

115114
timeout = self.timeout
@@ -124,6 +123,9 @@ def _execute_download_request(
124123
stream=stream,
125124
)
126125

126+
if not response.ok:
127+
return _validate_response(response)
128+
127129
# If we stream an iterator for streaming the content, otherwise return the entire byte array
128130
if stream:
129131
return response

0 commit comments

Comments
 (0)