From c18e97abf5db4ebe5e959276d53f7e19274682b4 Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 13 Jan 2026 17:10:22 +0100 Subject: [PATCH 1/9] provide way to resolve 429 for the Netherlands --- R/get_pvol_nl.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/R/get_pvol_nl.R b/R/get_pvol_nl.R index 4fbba7f..094c84f 100644 --- a/R/get_pvol_nl.R +++ b/R/get_pvol_nl.R @@ -70,6 +70,19 @@ get_pvol_nl <- function(radar, time, ..., call = rlang::caller_env()) { class = "getRad_error_get_pvol_nl_authorization_failure", call = call ) + }, + httr2_http_429 = function(cnd) { + cli::cli_abort( + c( + "There was a rate limitation error (HTTP 429) while getting data from the Netherlands.", + "i" = "This frequently occurs when using the anonymous key, if it occurs repeatedly consider requesting a registered key ({.url https://developer.dataplatform.knmi.nl/open-data-api#token}). ", + "i" = "You can check the current value of {.val nl_api_key} with + {.code get_secret(\"nl_api_key\")}." + ), + cnd = cnd, + class = "getRad_error_get_pvol_nl_429_failure", + call = call + ) } ) # This request retrieves the file From ccb0f0b5d3d64190a871c4a7444e96aaae1b6b37 Mon Sep 17 00:00:00 2001 From: Bart Date: Thu, 8 Jan 2026 10:45:30 +0100 Subject: [PATCH 2/9] Make tests flexible for new year --- tests/testthat/test-get_vpts_coverage_rmi.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-get_vpts_coverage_rmi.R b/tests/testthat/test-get_vpts_coverage_rmi.R index 36319c4..3701504 100644 --- a/tests/testthat/test-get_vpts_coverage_rmi.R +++ b/tests/testthat/test-get_vpts_coverage_rmi.R @@ -41,7 +41,7 @@ test_that("get_vpts_coverage_rmi() returns known radars and years", { expect_in( lubridate::year(cov$date), - seq(2019, 2025) + seq(2019, lubridate::year(Sys.Date())) ) }) From 4a9fd85bfc4ef915ea10bb87b763877663abcbc6 Mon Sep 17 00:00:00 2001 From: Bart Date: Thu, 8 Jan 2026 11:05:33 +0100 Subject: [PATCH 3/9] More files present now --- tests/testthat/test-get_pvol_ro.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-get_pvol_ro.R b/tests/testthat/test-get_pvol_ro.R index b52a736..b5822d9 100644 --- a/tests/testthat/test-get_pvol_ro.R +++ b/tests/testthat/test-get_pvol_ro.R @@ -11,7 +11,8 @@ test_that("Check if the available attributes changed", { unique() |> gsub(pattern = ".hdf", replacement = "") |> sort(), - c("KDP", "RhoHV", "V", "ZDR", "dBZ") |> sort() + c("Height", "KDP", "RhoHV", "V", "ZDR", "dBR", "dBZ") |> sort() + # Height and dBR are none polar files ) }) test_that("Pvol for Romania can be downloaded", { From e762510fbbe245f02bfbcbc9d716d24bd51a94af Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 13 Jan 2026 14:49:41 +0100 Subject: [PATCH 4/9] remove duplicated test --- tests/testthat/test-get_pvol_nl.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/testthat/test-get_pvol_nl.R b/tests/testthat/test-get_pvol_nl.R index 783bbd6..cfb08d8 100644 --- a/tests/testthat/test-get_pvol_nl.R +++ b/tests/testthat/test-get_pvol_nl.R @@ -13,10 +13,6 @@ test_that("Pvol for the Netherlands can be downloaded", { ) ) time <- as.POSIXct("2024-4-4 20:00:00", tz = "Europe/Helsinki") - expect_s3_class( - get_pvol("nlhrw", time, param = "all"), - "pvol" - ) pvol <- expect_s3_class(get_pvol("nlhrw", time, param = "all"), "pvol") expect_true(bioRad::is.pvol(pvol)) expect_identical( From 8d20edcf7c8824ccff41e6d506023c8a30897151 Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 13 Jan 2026 17:45:52 +0100 Subject: [PATCH 5/9] try secret key --- .github/workflows/R-CMD-check.yaml | 1 + tests/testthat/test-get_pvol_nl.R | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 0cb3593..aa141bd 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -29,6 +29,7 @@ jobs: - {os: ubuntu-latest, r: '4.1.0'} env: + getrad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes diff --git a/tests/testthat/test-get_pvol_nl.R b/tests/testthat/test-get_pvol_nl.R index cfb08d8..e1b77ec 100644 --- a/tests/testthat/test-get_pvol_nl.R +++ b/tests/testthat/test-get_pvol_nl.R @@ -30,12 +30,6 @@ test_that("Pvol for the Netherlands can be downloaded. Incorrect converter resul "keyring_backend" = "env", "getRad.nl_converter" = "ls" )) - # get public key here https://developer.dataplatform.knmi.nl/open-data-api#token - withr::local_envvar( - list( - "getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9" - ) - ) time <- as.POSIXct("2024-4-4 20:00:00", tz = "Europe/Helsinki") expect_error( get_pvol("nlhrw", time, param = "all"), From 37be0a80720ff9d54616c0a8ef012b30ecd2c9e5 Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 13 Jan 2026 18:26:18 +0100 Subject: [PATCH 6/9] typo --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index aa141bd..f67292d 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -29,7 +29,7 @@ jobs: - {os: ubuntu-latest, r: '4.1.0'} env: - getrad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }} + getRad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes From 9e3fb86c6ac3096d214c8290727a6e4616927fa0 Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 13 Jan 2026 19:00:11 +0100 Subject: [PATCH 7/9] Make sure there is a fall back on the anonymous key and use the secret in regular checks --- .github/workflows/regular-checks.yaml | 1 + tests/testthat/test-get_pvol_nl.R | 40 ++++++++++++++++++++------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.github/workflows/regular-checks.yaml b/.github/workflows/regular-checks.yaml index 8967ac5..5c8cbc5 100644 --- a/.github/workflows/regular-checks.yaml +++ b/.github/workflows/regular-checks.yaml @@ -22,6 +22,7 @@ jobs: - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} env: + getRad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes diff --git a/tests/testthat/test-get_pvol_nl.R b/tests/testthat/test-get_pvol_nl.R index e1b77ec..f753e63 100644 --- a/tests/testthat/test-get_pvol_nl.R +++ b/tests/testthat/test-get_pvol_nl.R @@ -2,16 +2,21 @@ test_that("Pvol for the Netherlands can be downloaded", { skip_if(Sys.which("KNMI_vol_h5_to_ODIM_h5") == "") skip_if_offline(host = "api.dataplatform.knmi.nl") - # make sure local env is used by keyring so that api key can be set - withr::local_options(list( - "keyring_backend" = "env" - )) - # get public key here https://developer.dataplatform.knmi.nl/open-data-api#token - withr::local_envvar( - list( - "getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9" + # First see if a key can be retrieved if not make sure env is used as a keyring backend + if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) { + withr::local_options(list( + "keyring_backend" = "env" + )) + } + # If no key can be retrieved from the current backend set the key to the anonymous key of KNMI + if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) { + # get public key here https://developer.dataplatform.knmi.nl/open-data-api#token + withr::local_envvar( + list( + "getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9" + ) ) - ) + } time <- as.POSIXct("2024-4-4 20:00:00", tz = "Europe/Helsinki") pvol <- expect_s3_class(get_pvol("nlhrw", time, param = "all"), "pvol") expect_true(bioRad::is.pvol(pvol)) @@ -27,9 +32,24 @@ test_that("Pvol for the Netherlands can be downloaded. Incorrect converter resul # make sure local env is used by keyring so that api key can be set withr::local_options(list( - "keyring_backend" = "env", "getRad.nl_converter" = "ls" )) + + # First see if a key can be retrieved if not make sure env is used as a keyring backend + if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) { + withr::local_options(list( + "keyring_backend" = "env" + )) + } + # If no key can be retrieved from the current backend set the key to the anonymous key of KNMI + if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) { + # get public key here https://developer.dataplatform.knmi.nl/open-data-api#token + withr::local_envvar( + list( + "getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9" + ) + ) + } time <- as.POSIXct("2024-4-4 20:00:00", tz = "Europe/Helsinki") expect_error( get_pvol("nlhrw", time, param = "all"), From e46bac85101ecfb2a1dd32d7ae8b6cc7d2cecbb1 Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 13 Jan 2026 19:17:21 +0100 Subject: [PATCH 8/9] make tests work again --- .github/workflows/test-coverage.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 0ab748d..1d28b2b 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -13,6 +13,7 @@ jobs: test-coverage: runs-on: ubuntu-latest env: + getRad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: From 3937ee6d2de5e0f2a5d7302443d292cfa1e6689b Mon Sep 17 00:00:00 2001 From: Bart Date: Wed, 14 Jan 2026 12:24:35 +0100 Subject: [PATCH 9/9] add news --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 33950bd..672e556 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # getRad (development version) +* Clarify HTTP 429 error for the Netherlands (#165). + # getRad 0.2.4 * Make error messages more consistent (#146).