Skip to content

Commit

Permalink
Fixes #855 (#857)
Browse files Browse the repository at this point in the history
* Fixes #855

* Update README

* Ensures failure on any error code except 404

---------

Co-authored-by: Julia Silge <julia.silge@gmail.com>
  • Loading branch information
edgararuiz and juliasilge authored Feb 1, 2025
1 parent dc519cf commit 0898a51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

* Improved documentation for S3-compatible object storage (#853).

* Prepends 'https://' to Databricks host if missing (#855).

# pins 1.4.0

## Lifecycle changes
Expand Down
18 changes: 12 additions & 6 deletions R/board_databricks.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#'
#' @inheritParams new_board
#' @param folder_url The path to the target folder inside Unity Catalog. The path
#' must include the catalog, schema, and volume names, preceded by 'Volumes/',
#' must include the catalog, schema, and volume names, preceded by 'Volumes/',
#' like `"/Volumes/my-catalog/my-schema/my-volume"`.
#' @param host Your [Workspace Instance URL](https://docs.databricks.com/en/workspace/workspace-details.html#workspace-url).
#' Defaults to `NULL`. If `NULL`, it will search for this URL in two different
#' Defaults to `NULL`. If `NULL`, it will search for this URL in two different
#' environment variables, in this order:
#' - 'DATABRICKS_HOST'
#' - 'CONNECT_DATABRICKS_HOST'
Expand Down Expand Up @@ -311,17 +311,23 @@ db_list_contents <- function(board, path = NULL) {
if (inherits(cond, "httr2_http_404")) {
return(list())
} else {
return(cond)
cli::cli_abort(
message = unlist(strsplit(out, "\n")),
call = NULL
)
}
}
out <- httr2::resp_body_json(out)
purrr::list_flatten(out)
}

db_req_init <- function(board, method, path) {
host_url <- httr2::url_parse(board$host)
if (is.null(host_url$scheme)) host_url$scheme <- "https"
out <- httr2::url_build(host_url)
host_url <- board$host
if (!grepl("^https?://", host_url)) {
host_url <- paste0("https://", host_url)
}
out <- httr2::url_parse(host_url)
out <- httr2::url_build(out)
out <- httr2::request(out)
out <- httr2::req_method(out, method)
out <- httr2::req_auth_bearer_token(out, db_get_token())
Expand Down

0 comments on commit 0898a51

Please sign in to comment.