From 3483e711083f3da48215ad21e3cf5a2d597203f8 Mon Sep 17 00:00:00 2001 From: ump45nose <52391318+ump45nose@users.noreply.github.com> Date: Wed, 21 Oct 2026 23:05:24 +0800 Subject: [PATCH 1/4] fix(r/adbcdrivermanager): don't truncate long error messages R truncates printed error messages to getOption("warning.length") (1000 characters by default), so long driver manager messages such as the list of paths searched for manifests were cut off. Raise the limit while stop_for_error() signals the condition. Closes #3450. --- r/adbcdrivermanager/R/error.R | 10 +++++++ .../tests/testthat/test-error.R | 27 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/r/adbcdrivermanager/R/error.R b/r/adbcdrivermanager/R/error.R index a7c3eeb8d88..8cefae84494 100644 --- a/r/adbcdrivermanager/R/error.R +++ b/r/adbcdrivermanager/R/error.R @@ -75,6 +75,16 @@ stop_for_error <- function(status, error) { # Store the listified error information cnd$error <- error + # R truncates printed error messages to getOption("warning.length") + # characters (1000 by default), which cuts off long driver manager + # messages such as the list of paths searched for a driver manifest. + # Raise the limit to its maximum while the error is signalled so the + # full message is shown; the option is restored when stop() unwinds. + if (nchar(msg, type = "bytes") > getOption("warning.length", 1000L)) { + old_options <- options(warning.length = 8170L) + on.exit(options(old_options), add = TRUE) + } + stop(cnd) } } diff --git a/r/adbcdrivermanager/tests/testthat/test-error.R b/r/adbcdrivermanager/tests/testthat/test-error.R index afffa241e45..ce8912c053e 100644 --- a/r/adbcdrivermanager/tests/testthat/test-error.R +++ b/r/adbcdrivermanager/tests/testthat/test-error.R @@ -41,6 +41,33 @@ test_that("error allocator works", { expect_identical(err$details, setNames(list(), character())) }) +test_that("stop_for_error() does not truncate long error messages", { + # Long messages (e.g., the list of paths searched for a driver manifest) + # should not be cut off at the default warning.length of 1000 characters + old_options <- options(warning.length = 1000L) + on.exit(options(old_options)) + + warning_length_while_signalled <- NULL + had_error <- FALSE + tryCatch( + withCallingHandlers( + adbc_driver(paste0("not_a_driver_", strrep("x", 1000))), + adbc_status = function(e) { + warning_length_while_signalled <<- getOption("warning.length") + } + ), + adbc_status = function(e) { + had_error <<- TRUE + expect_gt(nchar(conditionMessage(e), type = "bytes"), 1000) + } + ) + + expect_true(had_error) + expect_identical(warning_length_while_signalled, 8170L) + # The option is restored after the error was signalled + expect_identical(getOption("warning.length"), 1000L) +}) + test_that("stop_for_error() gives a custom error class with extra info", { had_error <- FALSE tryCatch({ From 579d7341213b9db71f24716061e9742915cf00b0 Mon Sep 17 00:00:00 2001 From: ump45nose <52391318+ump45nose@users.noreply.github.com> Date: Thu, 22 Oct 2026 11:25:38 +0800 Subject: [PATCH 2/4] fix(r/adbcdrivermanager): always raise warning.length while signalling errors --- r/adbcdrivermanager/R/error.R | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/r/adbcdrivermanager/R/error.R b/r/adbcdrivermanager/R/error.R index 8cefae84494..cf19c985482 100644 --- a/r/adbcdrivermanager/R/error.R +++ b/r/adbcdrivermanager/R/error.R @@ -78,12 +78,11 @@ stop_for_error <- function(status, error) { # R truncates printed error messages to getOption("warning.length") # characters (1000 by default), which cuts off long driver manager # messages such as the list of paths searched for a driver manifest. - # Raise the limit to its maximum while the error is signalled so the - # full message is shown; the option is restored when stop() unwinds. - if (nchar(msg, type = "bytes") > getOption("warning.length", 1000L)) { - old_options <- options(warning.length = 8170L) - on.exit(options(old_options), add = TRUE) - } + # The limit applies to the whole printed message, including the + # "Error in :" prefix, so always raise it to its maximum while + # the error is signalled; the option is restored when stop() unwinds. + old_options <- options(warning.length = 8170L) + on.exit(options(old_options), add = TRUE) stop(cnd) } From fd8cd23c46f48f95e2a051db0e2b6217177bbc87 Mon Sep 17 00:00:00 2001 From: Vincent <52391318+ump45nose@users.noreply.github.com> Date: Thu, 5 Nov 2026 21:08:26 +0800 Subject: [PATCH 3/4] fix(r/adbcdrivermanager): shorten warning.length comment Signed-off-by: Vincent <52391318+ump45nose@users.noreply.github.com> --- r/adbcdrivermanager/R/error.R | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/r/adbcdrivermanager/R/error.R b/r/adbcdrivermanager/R/error.R index cf19c985482..5d9aadeed63 100644 --- a/r/adbcdrivermanager/R/error.R +++ b/r/adbcdrivermanager/R/error.R @@ -75,12 +75,8 @@ stop_for_error <- function(status, error) { # Store the listified error information cnd$error <- error - # R truncates printed error messages to getOption("warning.length") - # characters (1000 by default), which cuts off long driver manager - # messages such as the list of paths searched for a driver manifest. - # The limit applies to the whole printed message, including the - # "Error in :" prefix, so always raise it to its maximum while - # the error is signalled; the option is restored when stop() unwinds. + # Always temporarily raise warning.length to its maximum so driver manager + # errors don't get truncated old_options <- options(warning.length = 8170L) on.exit(options(old_options), add = TRUE) From f03cd4cd477e74fb4630347b8a25dc477243ed9c Mon Sep 17 00:00:00 2001 From: yuwk <1729065730@qq.com> Date: Wed, 18 Nov 2026 02:51:39 +0800 Subject: [PATCH 4/4] fix(r/adbcdrivermanager): build the long error message from search paths The truncation test relied on a 1013-byte driver name, which is not a filename component any filesystem accepts. Point ADBC_DRIVER_PATH at six 210-byte directories instead: the driver manager lists every search path in the error, so the message still runs past the default warning.length of 1000 characters, and no single filename component is over-long. Upstream long filenames are handled since apache/arrow-adbc#4995, so the over-long name is no longer needed to reach the manifest search. --- .../tests/testthat/test-error.R | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/r/adbcdrivermanager/tests/testthat/test-error.R b/r/adbcdrivermanager/tests/testthat/test-error.R index ce8912c053e..69cc36dd36c 100644 --- a/r/adbcdrivermanager/tests/testthat/test-error.R +++ b/r/adbcdrivermanager/tests/testthat/test-error.R @@ -47,19 +47,27 @@ test_that("stop_for_error() does not truncate long error messages", { old_options <- options(warning.length = 1000L) on.exit(options(old_options)) + # The long message comes from the driver search paths, which the error lists + # in full, rather than from an over-long filename component: a name over 255 + # bytes is not a filename that any filesystem accepts. + search_dirs <- file.path(tempdir(), paste0(strrep("s", 200), seq_len(6))) + warning_length_while_signalled <- NULL had_error <- FALSE - tryCatch( - withCallingHandlers( - adbc_driver(paste0("not_a_driver_", strrep("x", 1000))), + withr::with_envvar( + list(ADBC_DRIVER_PATH = paste(search_dirs, collapse = .Platform$path.sep)), + tryCatch( + withCallingHandlers( + adbc_driver("not_a_driver"), + adbc_status = function(e) { + warning_length_while_signalled <<- getOption("warning.length") + } + ), adbc_status = function(e) { - warning_length_while_signalled <<- getOption("warning.length") + had_error <<- TRUE + expect_gt(nchar(conditionMessage(e), type = "bytes"), 1000) } - ), - adbc_status = function(e) { - had_error <<- TRUE - expect_gt(nchar(conditionMessage(e), type = "bytes"), 1000) - } + ) ) expect_true(had_error)