From 32adc18a5bd561c4b780740d04c87383b90a0759 Mon Sep 17 00:00:00 2001 From: Colin Gillespie Date: Fri, 16 Oct 2026 18:14:05 +0100 Subject: [PATCH 1/2] fix: Report a Posit version that couldn't be found instead of erroring audit_posit_version() and get_quarto_posit_version_msg() accept NA or character(0), so a Workbench session without rstudio-server on the PATH doesn't stop the audit. Needed by jumpingrivers/audit.workbench#38 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BEZ4ZUv51gFQjAe1WePbJF --- R/posit_versions.R | 11 ++++++++++- R/quarto-helpers.R | 3 +++ tests/testthat/test-posit_versions.R | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/R/posit_versions.R b/R/posit_versions.R index 0eb5525..6d2956c 100644 --- a/R/posit_versions.R +++ b/R/posit_versions.R @@ -59,6 +59,10 @@ audit_posit_version = function( type = c("connect", "workbench", "drivers") ) { type = match.arg(type) + if (is_missing_version(posit_version)) { + cli::cli_alert_info("Couldn't find which version of Posit {type} is installed") + return(invisible(NULL)) + } versions = get_posit_versions(type = type) row_number = lookup_version(posit_version, type = type) @@ -107,13 +111,18 @@ lookup_version = function(posit_version, type) { version_to_date = function(version) { # Old style version - if (!is_new_version(version)) { + if (is_missing_version(version) || !is_new_version(version)) { return(NA) } as_date = stringr::str_match_all(version, "^(202[0-9])\\.([01][0-9])")[[1]] as.Date(paste(as_date[1, 2], as_date[1, 3], "01", sep = "-")) } +# NA or character(0) when the version couldn't be found +is_missing_version = function(version) { + length(version) != 1L || is.na(version) +} + # Old style versions are 1.9.0 (2021-07) is_new_version = function(version) { stringr::str_detect(version, pattern = "^202[0-9]\\.[01][0-9].[0-9]") diff --git a/R/quarto-helpers.R b/R/quarto-helpers.R index b0ca65e..ca12f6c 100644 --- a/R/quarto-helpers.R +++ b/R/quarto-helpers.R @@ -76,6 +76,9 @@ get_quarto_posit_version_msg = function( type = c("connect", "workbench", "drivers") ) { posit_version = out$posit_version + if (is_missing_version(posit_version)) { + return(glue::glue("We couldn't find which version of Posit {type} is installed.")) + } row_number = lookup_version(posit_version, type) status = version_status(row_number) if (status == "unknown") { diff --git a/tests/testthat/test-posit_versions.R b/tests/testthat/test-posit_versions.R index 9c6980e..904ed94 100644 --- a/tests/testthat/test-posit_versions.R +++ b/tests/testthat/test-posit_versions.R @@ -73,3 +73,11 @@ test_that("count_cves() counts each CVE once", { expect_equal(count_cves(versions), 2L) expect_equal(count_cves(versions[4, ]), 0L) }) + +test_that("A version that couldn't be found is reported, not an error", { + for (version in list(NA_character_, character(0))) { + expect_message(audit_posit_version(version, "workbench"), "Couldn't find") + msg = get_quarto_posit_version_msg(list(posit_version = version), "workbench") + expect_match(msg, "couldn't find") + } +}) From 353d88444afff07f64f01610db5b5771a1a0ed86 Mon Sep 17 00:00:00 2001 From: Colin Gillespie Date: Fri, 16 Oct 2026 18:14:05 +0100 Subject: [PATCH 2/2] chore: Bump version to 0.7.8 --- DESCRIPTION | 2 +- NEWS.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5c0b459..3d3cd6e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: audit.base Title: Base package for Posit Checks -Version: 0.7.7 +Version: 0.7.8 Authors@R: person("Jumping", "Rivers", , "info@jumpingrivers.com", role = c("aut", "cre")) Description: Base package for sharing classes between posit audit diff --git a/NEWS.md b/NEWS.md index d57a451..0f52e04 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# audit.base 0.7.8 _2026-10-16_ + * fix: `audit_posit_version()` and `get_quarto_posit_version_msg()` say the Posit version couldn't be found when it's `NA`, instead of erroring (jumpingrivers/audit.workbench#38) + # audit.base 0.7.7 _2026-10-16_ * fix: `clean_libs()` strips only the architecture from RHEL package names, so names with dots, such as `java-1.8.0-openjdk-devel`, `libgit2_1.7-devel` and `gdal3.4`, are no longer reported missing. `get_installed_libs()` lists names with `rpm -qa`, which also works on SUSE (#59)