diff --git a/DESCRIPTION b/DESCRIPTION index 8ffc3210..02112375 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: orderly2 Title: Orderly Next Generation -Version: 1.99.17 +Version: 1.99.18 Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"), email = "rich.fitzjohn@gmail.com"), person("Robert", "Ashton", role = "aut"), diff --git a/R/location.R b/R/location.R index ba0247f3..7c8c1076 100644 --- a/R/location.R +++ b/R/location.R @@ -313,6 +313,23 @@ orderly_location_pull_packet <- function(..., options = NULL, recursive = NULL, ids <- orderly_search(..., options = options, root = root) } + if (length(ids) == 0) { + if (options$allow_remote && !options$pull_metadata) { + pull_arg <- gsub(" ", "\u00a0", "options = list(pull_metadata = TRUE)") + hint <- c(i = paste("Did you forget to pull metadata? You can do this", + "by using the argument '{pull_arg}' in the call", + "to 'orderly_location_pull_packet()', or", + "by running 'orderly_location_pull_metadata()'")) + } else { + hint <- NULL + } + cli::cli_abort( + c("No packets found in query, so cannot pull anything", + i = paste("Your query returned no packets, which is probably a mistake", + "so I'm erroring here."), + hint)) + } + plan <- location_build_pull_plan(ids, options$locations, recursive, root, call = environment()) diff --git a/tests/testthat/test-location.R b/tests/testthat/test-location.R index b24aec9d..370278ad 100644 --- a/tests/testthat/test-location.R +++ b/tests/testthat/test-location.R @@ -392,6 +392,21 @@ test_that("can pull a packet from one location to another, using file store", { }) +test_that("can error where a query returns no packets", { + root <- list() + for (name in c("src", "dst")) { + root[[name]] <- create_temporary_root() + } + + id <- create_random_packet(root$src) + orderly_location_add("src", "path", list(path = root$src$path), + root = root$dst) + err <- expect_error( + orderly_location_pull_packet(name = "data", root = root$dst), + "No packets found in query, so cannot pull anything") +}) + + test_that("can pull a packet from one location to another, archive only", { root <- list() for (name in c("src", "dst")) {