vubiostat / redcapAPI

R interface to REDCap (http://www.project-redcap.org/)
21 stars 27 forks source link

Fix Breakage due to 14.4.0 API Change (importUsers) #390

Closed spgarbet closed 5 months ago

spgarbet commented 5 months ago

The new version of REDCap 14.4.0 API breaks the importUsers call from this library.

Failure ('test-101-userMethods-ArgumentValidation.R:132:5'): Validate config, api_param
`importUsers(rcon, data = ProjectUser, config = list(1))` threw an error with unexpected message.
Expected match: "'config': Must have names"
Actual message: "1 assertions failed:\n * Variable 'names(data)': Must be a subset of\n * {'username','email','firstname','lastname','expiration','data_access_group','data_access_group_id','design','alerts','user_rights','data_access_groups','reports','stats_and_charts','manage_survey_participants','calendar','data_import_tool','data_comparison_tool','logging','file_repository','data_quality_create','data_quality_execute','api_export','api_import','api_modules','mobile_app','mobile_app_download_data','record_create','record_rename','record_delete','lock_records_all_forms','lock_records','lock_records_customization','mycap_participants','random_setup','random_dashboard','random_perform','forms','forms_export','record_id_form_access','record_id_export_access','data_export'},\n * but has additional elements {'email_logging'}."
Backtrace:
    ▆
 1. ├─testthat::expect_error(...) at test-101-userMethods-ArgumentValidation.R:132:5
 2. │ └─testthat:::quasi_capture(...)
 3. │   ├─testthat (local) .capture(...)
 4. │   │ └─base::withCallingHandlers(...)
 5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
 6. ├─redcapAPI::importUsers(rcon, data = ProjectUser, config = list(1))
 7. └─redcapAPI:::importUsers.redcapApiConnection(...) at redcapapi/R/importUsers.R:6:3
 8.   └─checkmate::reportAssertions(coll) at redcapapi/R/importUsers.R:49:3
Failure ('test-101-userMethods-ArgumentValidation.R:136:5'): Validate config, api_param
`importUsers(rcon, data = ProjectUser, config = "not a list")` threw an error with unexpected message.
Expected match: "'config': Must be of type 'list'"
Actual message: "1 assertions failed:\n * Variable 'names(data)': Must be a subset of\n * {'username','email','firstname','lastname','expiration','data_access_group','data_access_group_id','design','alerts','user_rights','data_access_groups','reports','stats_and_charts','manage_survey_participants','calendar','data_import_tool','data_comparison_tool','logging','file_repository','data_quality_create','data_quality_execute','api_export','api_import','api_modules','mobile_app','mobile_app_download_data','record_create','record_rename','record_delete','lock_records_all_forms','lock_records','lock_records_customization','mycap_participants','random_setup','random_dashboard','random_perform','forms','forms_export','record_id_form_access','record_id_export_access','data_export'},\n * but has additional elements {'email_logging'}."
Backtrace:
    ▆
 1. ├─testthat::expect_error(...) at test-101-userMethods-ArgumentValidation.R:136:5
 2. │ └─testthat:::quasi_capture(...)
 3. │   ├─testthat (local) .capture(...)
 4. │   │ └─base::withCallingHandlers(...)
 5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
 6. ├─redcapAPI::importUsers(rcon, data = ProjectUser, config = "not a list")
 7. └─redcapAPI:::importUsers.redcapApiConnection(...) at redcapapi/R/importUsers.R:6:3
 8.   └─checkmate::reportAssertions(coll) at redcapapi/R/importUsers.R:49:3
Failure ('test-101-userMethods-ArgumentValidation.R:141:5'): Validate config, api_param
`importUsers(rcon, data = ProjectUser, api_param = list(1))` threw an error with unexpected message.
Expected match: "'api_param': Must have names"
Actual message: "1 assertions failed:\n * Variable 'names(data)': Must be a subset of\n * {'username','email','firstname','lastname','expiration','data_access_group','data_access_group_id','design','alerts','user_rights','data_access_groups','reports','stats_and_charts','manage_survey_participants','calendar','data_import_tool','data_comparison_tool','logging','file_repository','data_quality_create','data_quality_execute','api_export','api_import','api_modules','mobile_app','mobile_app_download_data','record_create','record_rename','record_delete','lock_records_all_forms','lock_records','lock_records_customization','mycap_participants','random_setup','random_dashboard','random_perform','forms','forms_export','record_id_form_access','record_id_export_access','data_export'},\n * but has additional elements {'email_logging'}."
Backtrace:
    ▆
 1. ├─testthat::expect_error(...) at test-101-userMethods-ArgumentValidation.R:141:5
 2. │ └─testthat:::quasi_capture(...)
 3. │   ├─testthat (local) .capture(...)
 4. │   │ └─base::withCallingHandlers(...)
 5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
 6. ├─redcapAPI::importUsers(rcon, data = ProjectUser, api_param = list(1))
 7. └─redcapAPI:::importUsers.redcapApiConnection(...) at redcapapi/R/importUsers.R:6:3
 8.   └─checkmate::reportAssertions(coll) at redcapapi/R/importUsers.R:49:3
Failure ('test-101-userMethods-ArgumentValidation.R:145:5'): Validate config, api_param
`importUsers(rcon, data = ProjectUser, api_param = "not a list")` threw an error with unexpected message.
Expected match: "'api_param': Must be of type 'list'"
Actual message: "1 assertions failed:\n * Variable 'names(data)': Must be a subset of\n * {'username','email','firstname','lastname','expiration','data_access_group','data_access_group_id','design','alerts','user_rights','data_access_groups','reports','stats_and_charts','manage_survey_participants','calendar','data_import_tool','data_comparison_tool','logging','file_repository','data_quality_create','data_quality_execute','api_export','api_import','api_modules','mobile_app','mobile_app_download_data','record_create','record_rename','record_delete','lock_records_all_forms','lock_records','lock_records_customization','mycap_participants','random_setup','random_dashboard','random_perform','forms','forms_export','record_id_form_access','record_id_export_access','data_export'},\n * but has additional elements {'email_logging'}."
Backtrace:
    ▆
 1. ├─testthat::expect_error(...) at test-101-userMethods-ArgumentValidation.R:145:5
 2. │ └─testthat:::quasi_capture(...)
 3. │   ├─testthat (local) .capture(...)
 4. │   │ └─base::withCallingHandlers(...)
 5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
 6. ├─redcapAPI::importUsers(rcon, data = ProjectUser, api_param = "not a list")
 7. └─redcapAPI:::importUsers.redcapApiConnection(...) at redcapapi/R/importUsers.R:6:3
 8.   └─checkmate::reportAssertions(coll) at redcapapi/R/importUsers.R:49:3
Error ('test-357-prepUserImportData.R:15:5'): Use consolidate = TRUE
Error in `devtools::test(stop_on_failure = TRUE)`: 1 assertions failed:
 * Variable 'primary_fields': Must be a subset of
 * {'username','email','firstname','lastname','expiration','data_access_group','data_access_group_id','design','alerts','user_rights','data_access_groups','reports','stats_and_charts','manage_survey_participants','calendar','data_import_tool','data_comparison_tool','logging','file_repository','data_quality_create','data_quality_execute','api_export','api_import','api_modules','mobile_app','mobile_app_download_data','record_create','record_rename','record_delete','lock_records_all_forms','lock_records','lock_records_customization','mycap_participants','random_setup','random_dashboard','random_perform','forms','forms_export','data_export'},
 * but has additional elements {'email_logging'}.
Backtrace:
    ▆
 1. └─redcapAPI::prepUserImportData(User, rcon) at test-357-prepUserImportData.R:15:5
 2.   └─checkmate::reportAssertions(coll) at redcapapi/R/prepUserImportData.R:92:3
Failure ('test-361-userStructureVersion.R:23:3'): Prep user import pre 14.0.3 fails if given api_modules
Expected `prepUserImportData(User, rcon = old_rcon)` to run without any errors.
i Actually got a <simpleError> with text:
  1 assertions failed:
   * Variable 'primary_fields': Must be a subset of
   * {'username','email','firstname','lastname','expiration','data_access_group','data_access_group_id','design','alerts','user_rights','data_access_groups','reports','stats_and_charts','manage_survey_participants','calendar','data_import_tool','data_comparison_tool','logging','file_repository','data_quality_create','data_quality_execute','api_export','api_import','api_modules','mobile_app','mobile_app_download_data','record_create','record_rename','record_delete','lock_records_all_forms','lock_records','lock_records_customization','mycap_participants','random_setup','random_dashboard','random_perform','forms','forms_export','data_export'},
   * but has additional elements {'email_logging'}.
[ FAIL 6 | WARN 0 | SKIP 12 | PASS 2019 ]
jubilee2 commented 5 months ago

I think this is not return from redcap server, this is pre verify within the redcapAPI package. I will discuss this @obregos

jubilee2 commented 5 months ago

@obregos and I think add email_logging into following list can solve issue. @obregos can you make a PR for this?

User API

https://github.com/vubiostat/redcapAPI/blob/main/R/redcapDataStructure.R#L310 https://github.com/vubiostat/redcapAPI/blob/main/R/redcapDataStructure.R#L354

User Role API

https://github.com/vubiostat/redcapAPI/blob/main/R/redcapDataStructure.R#L387 https://github.com/vubiostat/redcapAPI/blob/main/R/redcapDataStructure.R#L424