Closed llrs closed 2 years ago
thanks @llrs i'll take a look
What do you mean by "not properly recorded"? Is the cassette file empty? Or not empty, but incorrect?
@llrs I couldn't reproduce the problem with multiple params with the same name or with a route that ends with a number. Can you show what your cassette looks like and what errors you get if any
Sorry, forgot to report more information. This is the test:
test_that("get_user multiple ids", {
skip_on_cran()
expect_snapshot({
use_key()
})
vcr::use_cassette("get_user2", {
gu <- get_user(c(1, 2))
})
expect_equal(nrow(gu), 2)
expect_equal(ncol(gu), 3)
expect_equal(colnames(gu), c("real_name", "id", "can_login"))
expect_s3_class(gu, "data.frame")
})
This is the failure message I receive, when testing the package via the build panel on RStudio:
================================================================================
An HTTP request has been made that vcr does not know how to handle:
GET https://bugs.r-project.org/bugzilla/rest/user?ids=1&ids=2
vcr is currently using the following cassette:
- /home/lluis/Documents/Projects/bugRzilla/tests/fixtures/get_user2.yml
- record_mode: once
- match_requests_on: method, uri
Set `VCR_VERBOSE_ERRORS=TRUE` for more verbose errors
If you're not sure what to do, open an issue https://github.com/ropensci/vcr/issues
& see https://books.ropensci.org/http-testing
================================================================================
Backtrace:
1. vcr::use_cassette(...) test-get_user.R:20:4
3. bugRzilla::get_user(c(1, 2)) test-get_user.R:21:8
4. httr::GET(url, .state$headers) /home/lluis/Documents/Projects/bugRzilla/R/get_user.R:41:4
5. httr:::request_perform(req, hu$handle$handle)
6. httr:::perform_callback("request", req = req)
7. webmockr:::callback(...)
8. webmockr::HttrAdapter$new()$handle_request(req)
9. private$request_handler(req)$handle()
10. eval(parse(text = req_type_fun))(self$request)
11. err$run()
12. self$construct_message()
And this is on the fixture, not sure if incorrect, I would say it is correct but still I don't understand why when testing it warns me:
http_interactions:
- request:
method: get
uri: https://bugs.r-project.org/rest/user?ids=1&ids=2
body:
encoding: ''
string: ''
headers:
Accept: application/json, text/xml, application/xml, */*
X-BUGZILLA-API-KEY: Removing this header too just in case
User-Agent: https://github.com/llrs/bugRzilla/
response:
status:
status_code: 200
category: Success
reason: OK
message: 'Success: (200) OK'
headers:
server: nginx
date: Thu, 21 Oct 2021 20:55:29 GMT
content-type: application/json; charset=UTF-8
content-length: '215'
etag: mz+olahE9YOtDw3P3RaKZg
access-control-allow-headers: accept, content-type, origin, user-agent, x-requested-with,
x-bugzilla-login, x-bugzilla-token, x-bugzilla-password, x-bugzilla-api-key
access-control-allow-origin: '*'
content-security-policy: default-src 'self'; script-src 'self' 'unsafe-inline'
'unsafe-eval'; style-src 'self' 'unsafe-inline'
x-content-security-policy: default-src 'self'; script-src 'self' 'unsafe-inline'
'unsafe-eval'; style-src 'self' 'unsafe-inline'
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-webkit-csp: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval';
style-src 'self' 'unsafe-inline'
x-xss-protection: 1; mode=block
body:
encoding: UTF-8
file: no
string: '{"users":[{"can_login":true,"name":"admin@urbanek.info","id":1,"groups":[],"real_name":"Simon
Urbanek"},{"can_login":true,"name":"jitterbug-import","id":2,"groups":[],"real_name":"Jitterbug
compatibility account"}]}'
recorded_at: 2021-10-21 20:55:29 GMT
recorded_with: vcr/1.0.2, webmockr/0.8.0
Interesting, thanks for that. Will have a look
I don't understand how to get an API Key. Or how to sign up for the bugzilla service.
Hi @sckott to sign up on R bugzilla you first need to send an email to: bug-report-request@r-project.org and then you will be able to create an account (See full instructions here).
Once you have your profile and you are logged you can go to to your preferences and select API keys and create a new API key for bugs.r-project.org.
To then use it on the package you can use set_key(key = "your new R-Bugzilla key")
@llrs is this stil a problem?
I haven't touched that package in a year, but I have just tested it again and currently the problem seems to be in my side and not in the vcr. Probably an improvement in httr detected a bad request:
<http_400/http_error/error/condition>
Error in `get_user(c(1, 2))`: Bad Request (HTTP 400).
I'm closing the issue now. Thanks for following up!
thanks @llrs !
When making a request such as
GET https://bugs.r-project.org/bugzilla/rest/user?ids=1&ids=2
orhttps://bugs.r-project.org/bugzilla/rest/user/2
via httr it is accepted by httr but not properly recorded by vcr.I think the problem is with the multiple query arguments with the same name, which
httr::modify_url
does not accept, but this API uses and the use of an endpoint that ends with a number (I'm more lost on this one). Perhaps this is not common so I understand if it is not a priority.Note that to make such a request you will need authentication. Instructions and documentation on the package website and the PR I have problems https://github.com/llrs/bugRzilla/pull/10.
Session Info
```r ─ Session info ─────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.1.0 Patched (2021-06-17 r80510) os Ubuntu 20.04.3 LTS system x86_64, linux-gnu ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz Europe/Madrid date 2021-10-21 ─ Packages ─────────────────────────────────────────────────────────────────────────────────────── ! package * version date lib source askpass 1.1 2019-01-13 [1] CRAN (R 4.1.0) base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.1.0) P bugRzilla * 0.0.90001 2021-10-21 [?] local cachem 1.0.6 2021-08-19 [1] CRAN (R 4.1.0) callr 3.7.0 2021-04-20 [1] CRAN (R 4.1.0) cli 3.0.1 2021-07-17 [1] CRAN (R 4.1.0) commonmark 1.7 2018-12-01 [1] CRAN (R 4.1.0) crayon 1.4.1 2021-02-08 [1] CRAN (R 4.1.0) credentials 1.3.0 2020-07-21 [1] CRAN (R 4.1.0) crul 1.1.0 2021-02-15 [1] CRAN (R 4.1.0) curl 4.3.2 2021-06-23 [1] CRAN (R 4.1.0) desc 1.3.0 2021-03-05 [1] CRAN (R 4.1.0) devtools * 2.4.2 2021-06-07 [1] CRAN (R 4.1.0) digest 0.6.28 2021-09-23 [1] CRAN (R 4.1.0) ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0) evaluate 0.14 2019-05-28 [1] CRAN (R 4.1.0) fansi 0.5.0 2021-05-25 [1] CRAN (R 4.1.0) fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.0) fauxpas 0.5.0 2020-04-13 [1] CRAN (R 4.1.0) fs 1.5.0 2020-07-31 [1] CRAN (R 4.1.0) gert 1.3.1 2021-06-23 [1] CRAN (R 4.1.0) gh 1.3.0 2021-04-30 [1] CRAN (R 4.1.0) gitcreds 0.1.1 2020-12-04 [1] CRAN (R 4.1.0) glue 1.4.2 2020-08-27 [1] CRAN (R 4.1.0) htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.0) httpcode 0.3.0 2020-04-10 [1] CRAN (R 4.1.0) httr 1.4.2 2020-07-20 [1] CRAN (R 4.1.0) jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.1.0) knitr 1.36 2021-09-29 [1] CRAN (R 4.1.0) lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.1.0) magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.0) memoise 2.0.0 2021-01-26 [1] CRAN (R 4.1.0) openssl 1.4.5 2021-09-02 [1] CRAN (R 4.1.0) pillar 1.6.2 2021-07-29 [1] CRAN (R 4.1.0) pkgbuild 1.2.0 2020-12-15 [1] CRAN (R 4.1.0) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.0) pkgload 1.2.1 2021-04-06 [1] CRAN (R 4.1.0) prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.1.0) processx 3.5.2 2021-04-30 [1] CRAN (R 4.1.0) ps 1.6.0 2021-02-28 [1] CRAN (R 4.1.0) purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.0) R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.0) Rcpp 1.0.7 2021-07-07 [1] CRAN (R 4.1.0) remotes 2.4.0 2021-06-02 [1] CRAN (R 4.1.0) rlang 0.4.11 2021-04-30 [1] CRAN (R 4.1.0) rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.1.0) roxygen2 7.1.1 2020-06-27 [1] CRAN (R 4.1.0) rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.1.0) rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.0) sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.1.0) stringi 1.7.5 2021-10-04 [1] CRAN (R 4.1.0) stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.0) sys 3.4 2020-07-23 [1] CRAN (R 4.1.0) testthat 3.1.0 2021-10-04 [1] CRAN (R 4.1.0) tibble 3.1.4 2021-08-25 [1] CRAN (R 4.1.0) triebeard 0.3.0 2016-08-04 [1] CRAN (R 4.1.0) urltools 1.7.3 2019-04-14 [1] CRAN (R 4.1.0) usethis * 2.0.1 2021-02-10 [1] CRAN (R 4.1.0) utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.0) vcr 1.0.2 2021-05-31 [1] CRAN (R 4.1.0) vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.0) webmockr 0.8.0 2021-03-14 [1] CRAN (R 4.1.0) whisker 0.4 2019-08-28 [1] CRAN (R 4.1.0) withr 2.4.2 2021-04-18 [1] CRAN (R 4.1.0) xfun 0.26 2021-09-14 [1] CRAN (R 4.1.0) xml2 1.3.2 2020-04-23 [1] CRAN (R 4.1.0) yaml 2.2.1 2020-02-01 [1] CRAN (R 4.1.0) [1] /home/lluis/bin/R/4.1.0/lib/R/library P ── Loaded and on-disk path mismatch. ```