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/3] 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 a7c3eeb8d8..8cefae8449 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 afffa241e4..ce8912c053 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/3] 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 8cefae8449..cf19c98548 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/3] 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 cf19c98548..5d9aadeed6 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)