ctsit / rcc.billing

Automated, data-driven service billing implemented on REDCap Custodian
https://ctsit.github.io/rcc.billing/
Apache License 2.0
0 stars 3 forks source link

`sequester_unpaid_projects.R` sent multiple emails with an `NA` body #165

Closed pbchase closed 1 year ago

pbchase commented 1 year ago

On the 2023-07-04 run of sequester_unpaid_projects.R, multiple people with no name were sent emails that had "NA for the body. The "to" part of the address had only an email. They looked like this:

From: owner-redcap-billing-l@lists.ufl.edu owner-redcap-billing-l@lists.ufl.edu on behalf of ctsit-redcap-reply@ad.ufl.edu ctsit-redcap-reply@ad.ufl.edu Date: Tuesday, July 4, 2023 at 8:04 AM To: XXXX@XXX.ufl.edu XXXX@XXX.ufl.edu Cc: CTS-IT REDCap Billing redcap-billing-l@lists.ufl.edu, CTSI-SvcCntrBilling CTSI-SvcCntrBilling@ad.ufl.edu Subject: Unpaid REDCap projects sequestered

NA

Other people got complete normal emails. I suspect an NA name component caused the body to be NA as it also includes the name. Ths test verifies that assertion:

> str_replace("asdf foo", "asdf", "qwer")
[1] "qwer foo"
> str_replace("asdf foo", "asdf", as.character(NA))
[1] NA

The str_replace* functions do not tolerate NAs in the replacement strings. NAs in the replacement strings need to be converted ot a viable string before they are used.

pbchase commented 1 year ago

Adding a line like this to clean up the replacement strings would probably do the trick:

mutate(across(c("my", "replacement", "words"), stringr::str_replace_na)) %>%
pbchase commented 1 year ago

Addressed by PR #170