Skip to content

Commit 93235f5

Browse files
authored
Avoid passing a schemaless host to the Databricks CLI (#522)
Previously we were passing the host without the schema. I think this probably worked at some point in the past, but it does not work with modern versions of the Databricks CLI: $ databricks auth token --host example.cloud.databricks.com Error: host must start with 'https://': example.cloud.databricks.com This commit ensures we pass the complete workspace URL. Unit tests have been updated to verify this as well. Signed-off-by: Aaron Jacobs <[email protected]>
1 parent 3bf9b84 commit 93235f5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

R/provider-databricks.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ default_databricks_credentials <- function(workspace = databricks_workspace()) {
255255
# When on desktop, try using the Databricks CLI for auth.
256256
cli_path <- Sys.getenv("DATABRICKS_CLI_PATH", "databricks")
257257
if (!is_hosted_session() && nchar(Sys.which(cli_path)) != 0) {
258-
token <- databricks_cli_token(cli_path, host)
258+
token <- databricks_cli_token(cli_path, workspace)
259259
if (!is.null(token)) {
260260
return(function() {
261261
# Ensure we get an up-to-date token.
262-
token <- databricks_cli_token(cli_path, host)
262+
token <- databricks_cli_token(cli_path, workspace)
263263
list(Authorization = paste("Bearer", token))
264264
})
265265
}

tests/testthat/test-provider-databricks.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ test_that("Databricks CLI tokens are detected correctly", {
6565
DATABRICKS_CLIENT_ID = NA,
6666
DATABRICKS_CLIENT_SECRET = NA
6767
)
68-
local_mocked_bindings(databricks_cli_token = function(path, host) "cli_token")
68+
local_mocked_bindings(
69+
databricks_cli_token = function(path, host) {
70+
stopifnot(startsWith(host, "https://"))
71+
"cli_token"
72+
}
73+
)
6974

7075
credentials <- default_databricks_credentials()
7176
expect_equal(credentials(), list(Authorization = "Bearer cli_token"))

0 commit comments

Comments
 (0)