Skip to content

Commit 91a1324

Browse files
committed
better error message when a batch is too large
closes #400
1 parent da15592 commit 91a1324

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

NEWS.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Upcoming Versions
88
* `redcap_read()` and `redcap_read_oneshot()` accept a new `locale` parameter that specifies date, time, and number formats, like using a comma as the decimal separator. It is a [`readr::locale`](https://readr.tidyverse.org/reference/locale.html) object. (#377, suggested by @joundso)
99
* New `redcap_instruments()` function exports a list of the data collection instruments for a project. (#381, @vcastro)
1010
* New `redcap_event_instruments()` function exports the instrument-event mappings for a project (i.e., how the data collection instruments are designated for certain events in a longitudinal project).. (#381, @vcastro)
11+
* New detection when REDCap has trouble with a large request and drops records. (#400 w/ @TimMonahan)
1112

1213
### Minor Enhancements
1314

@@ -20,7 +21,7 @@ Upcoming Versions
2021
* Modify `redcap_users_export()` (which calls REDCap's user export). The API dropped the `data_export` variable and added the `forms_export` variable. (#396)
2122
* For `redcap_read_oneshot_eav()`: if the project isn't longitudinal, a dummy value for `event_id` is used internally (#396)
2223
* For the testing server & projects, the http errors are a little different, so the testing code was adjusted (#396)
23-
* Set `httr::user_agent`, following the advice of its vignette (#397)
24+
* Set `httr::user_agent`, following the advice of httr's vignette (#397)
2425

2526
### Test Suite
2627

R/redcap-read.R

+14-1
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,21 @@ redcap_read <- function(
400400
ids_missing_rows <- setdiff(unique_ids, unique_ids_actual)
401401

402402
if (0L < length(ids_missing_rows)) {
403+
message_template <-
404+
paste0(
405+
"There are %i subject(s) that are missing rows in the returned dataset. ",
406+
"REDCap's PHP code is likely trying to process too much text in one bite.\n\n",
407+
"Common solutions this problem are:\n",
408+
" - specifying only the records you need (w/ `records`)\n",
409+
" - specifying only the fields you need (w/ `fields`)\n",
410+
" - specifying only the forms you need (w/ `forms`)\n",
411+
" - specifying a subset w/ `filter_logic`\n",
412+
" - reduce `batch_size`\n\n",
413+
"The missing ids are:\n",
414+
"%s."
415+
)
403416
stop(sprintf(
404-
"There are %i subject(s) that are missing rows in the final dataset.\nCheck for funny values that could trip up REDCap's PHP code:\n%s.",
417+
message_template,
405418
length(ids_missing_rows),
406419
paste(ids_missing_rows, collapse=",")
407420
))

0 commit comments

Comments
 (0)