ropensci / vcr

Record and replay HTTP requests
https://docs.ropensci.org/vcr
Other
77 stars 12 forks source link

skip test that uses vcr if casssette is not UTF-8 #99

Open sckott opened 5 years ago

sckott commented 5 years ago

Arose from recent realization that strings in cassettes, any string in the cassette (not just the response body), that are not UTF-8 can cause problems on some platforms, e.g.,


Options:

sckott commented 5 years ago

I think best approach is to take the string from the cassette and replace any non ascii strings with unicode equivalent, or if none found, then drop the non-ascii, or something else? ideally would use stringi, but the pkg is so heavy so not sure want to import it. but could have as a Suggest and if not installed, then do something with base R. I like the idea of a filter before loading into yaml because then we don't touch the real request/response

probably happen on the line after this or so https://github.com/ropensci/vcr/blob/master/R/serializers-yaml.R#L76

maybe:

text_cleaner <- function(x) {
    if (requireNamespace("stringi")) {
        stringi::stri_escape_unicode(x)
    } else {
        # some other w/o stringi
    }
}
sckott commented 5 years ago

another reason to get that JSON serializer done sooner than later, it may help avoid these yaml pkg problems

maelle commented 3 years ago

another reason to get that JSON serializer done sooner than later, it may help avoid these yaml pkg problems

It seems so at least for my encoding problems. :-D

sckott commented 3 years ago

right. it'd be nice to have a better yaml pkg, but its easier here to just recommend people use json if they have any issue