Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-JSON response from Snowflake connection attempt results is not handled #3350

Closed
barberscott opened this issue May 12, 2021 · 1 comment · Fixed by #3365
Closed

Non-JSON response from Snowflake connection attempt results is not handled #3350

barberscott opened this issue May 12, 2021 · 1 comment · Fixed by #3365
Labels
bug Something isn't working snowflake

Comments

@barberscott
Copy link

It is possible via the Snowflake OAuth/SSO pathway that our attempt to obtain an access_token will fail for a variety of reasons. The resultant response may or may not be in JSON but this code assumes it always will be:

https:/fishtown-analytics/dbt/blob/d8c261ffcfab0da7974310760a74d7858756c3ed/plugins/snowflake/dbt/adapters/snowflake/connections.py#L128-L132

and errors out with Expecting value: line 1 column 1 (char 0) when receiving a non-JSON response.

@jtcohen6 jtcohen6 added snowflake bug Something isn't working labels May 12, 2021
@jtcohen6
Copy link
Contributor

Thanks for opening @barberscott, and for pointing to the relevant spot in the code!

I bet this is an easy thing to check and handle, the question will be doing it as quickly and reliably as possible. This is hardly my area of expertise, but from reading a bit online (i.e. this SO post), it sounds like we might be able to check the requests response metadata to see if the content type is JSON:

result = requests.post(token_url, headers=headers, data=data) 
if result.headers.get('content-type') == 'application/json':
  result_json = result.json()

If the response isn't JSON, we should call _get_access_token again, until we have a response that is.

Any chance this is a fix you'd be interested in contributing? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working snowflake
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants