Skip to content

Commit

Permalink
Add bug fix for SNOW-266042 Improve Query/Request ID logging (#629)
Browse files Browse the repository at this point in the history
* Add bug fix

* Update network.py

Remove None from dict.get
  • Loading branch information
sfc-gh-stan authored Feb 17, 2021
1 parent fbc70f8 commit 8207705
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/snowflake/connector/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def _post_request(self, url, headers, body, token=None,
return self._post_request(
url, headers, body, token=self.token, timeout=timeout)

if ret.get('data') and ret['data'].get('queryId'):
if isinstance(ret.get('data'), dict) and ret['data'].get('queryId'):
logger.debug('Query id: {}'.format(ret['data']['queryId']))

if ret.get('code') == QUERY_IN_PROGRESS_ASYNC_CODE and _no_results:
Expand Down Expand Up @@ -770,7 +770,7 @@ def _handle_unknown_error(self, method, full_url, headers, data, conn):
conn, None, OperationalError,
{
'msg': 'Failed to get the response. Hanging? '
'method: {method}, url: {url}'.format(
'method: {method}, url: {url}'.format(
method=method,
url=full_url,
),
Expand Down Expand Up @@ -846,7 +846,7 @@ def _request_exec(
self._connection, None, DatabaseError,
{
'msg': ('Failed to get authentication by OKTA: '
'{status}: {reason}').format(
'{status}: {reason}').format(
status=raw_ret.status_code,
reason=raw_ret.reason),
'errno': ER_FAILED_TO_CONNECT_TO_DB,
Expand All @@ -867,7 +867,7 @@ def _request_exec(
self._connection, None, InterfaceError,
{
'msg': ("{status} {reason}: "
"{method} {url}").format(
"{method} {url}").format(
status=raw_ret.status_code,
reason=raw_ret.reason,
method=method,
Expand Down

0 comments on commit 8207705

Please sign in to comment.