-
Notifications
You must be signed in to change notification settings - Fork 120
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
Esoteric Bug with regards to authentication via requests
headers=
argument being overwritten by .netrc
#337
Comments
Thanks for the bug report, we clearly missed this edge case. We'll address it soon. For the time being we'll not honour the .netrc file in dbt-databricks. Especially now with OAuth support, saving tokens locally should not be as important. |
Thanks for your response. I think it makes sense to ignore the Will look into OAuth support as well, thanks! |
I've written the fix and opened #338 |
https://requests.readthedocs.io/en/latest/user/authentication/#new-forms-of-authentication Closes #121 Affects databricks/dbt-databricks#337 Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
https://requests.readthedocs.io/en/latest/user/authentication/#new-forms-of-authentication Closes #121 Affects databricks/dbt-databricks#337 Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Closing as fixed. If the issue still exists, please reopen. |
@benc-db This issue still appears to happen as the fix wasn't merged yet, could we reopen? This issue breaks materialized views when a .netrc file is present. See #338 (comment). |
Btw here's a link to the bug in |
Describe the bug
It's an odd one that set me back around a day: I hope to save people a similar amount of frustration.
When running a python model on an all purpose cluster, I would get this error:
despite putting a brand new token into the
profiles.yml
for the target corresponding all purpose cluster.Turns out that the my
.netrc
file was to blame. It had an expired token for the samehost:
. Also turns out that therequests
library overrides authentication methods passed throughheader=
argument with the contents of the.netrc
file, as stated here: https://requests.readthedocs.io/en/latest/user/authentication/#netrc-authenticationTo be 100% clear, my
.netrc
file looked like this (replacing sensitive info below):.netrc
:My
.profiles
contained a target like:Then the weird part:
requests.py
does pass the<valid_token>
in to the headers argument in theget_cluster_status
call.requests.py
would give me an error from this method because it defaulted to my.netrc
token: https://github.com/databricks/dbt-databricks/blob/main/dbt/adapters/databricks/python_submissions.py#L245Steps To Reproduce
Fairly easy to trigger:
.netrc
file..netrc
file is encouraged in the Databricks API documentation~/.dbt/profiles.yml
for an all purpose cluster that we want to use to run a python model.Expected behavior
I'd expect the token provided in my
profiles.yml
to take precedence.Screenshots and log output
Not needed IMO, already know the cause.
System information
Relevant versions are:
dbt-databricks==1.5.0
requests==2.28.1
Additional context
I would say the solution is to ensure the
dbt-databricks
code uses theauth
argument instead. It seems a "bearer token" auth method doesn't come included inrequests
(which seems odd but okay). To this end there is a good SO solution to this: https://stackoverflow.com/a/58055668I would also highlight that while this feels like it might only be a me problem, Databricks has lots of docs around using
.netrc
file, as linked before: Databricks API documentation. Doesn't seem too far-fetched someone else will fall into this trap, and its a hard one to get out of.The text was updated successfully, but these errors were encountered: