TIBHannover / BacDiveR

Inofficial R client for the DSMZ's Bacterial Diversity Metadatabase (former contact: @katrinleinweber). https://api.bacdive.dsmz.de/client_examples seems to be the official alternatives.
https://TIBHannover.GitHub.io/BacDiveR/
MIT License
10 stars 12 forks source link

Blank search results and not error when password changed but not in Renviron file #110

Open jfy133 opened 4 years ago

jfy133 commented 4 years ago

I noticed the following problem: changing your BacDive API password, but (forgetting...) not updating the Renviron file accordingly, results in empty search results in no error.

To reproduce: firstly change your password in the Renviron file to an incorrect password.

> taxon_1 <- "Bacillus halodurans"
> Bac_data <- bd_retrieve_taxon(name = taxon_1) 

> Bac_data
 NULL
> taxon_2 <- "Aneurinibacillus thermoaerophilus"
> At_data <- bd_retrieve_taxon(name = taxon_2)

> At_data
  NULL

The search result is just a blank line. Assignment and printing of variable displays NULL. No error is displayed.

Updating to the correct password fixed the issue.

I identified that it was an invalid credentials error after I manually copied and pasted relevant functions of the BacDiveR source code, and ran the following

download(construct_url("Tannerella"))
 $detail
[1] "Invalid username/password"

This error does not appear to be passed to the higher level functions.

Additional information:

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8      
 [8] LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] BacDiveR_0.9.0

loaded via a namespace (and not attached):
[1] httr_1.4.1        compiler_3.6.1    R6_2.4.0          tools_3.6.1       curl_4.0          jsonlite_1.6.9000
I have...
katrinleinweber commented 4 years ago

Thanks for this report, @jfy133 :-)

It's an edge-case I forgot to consider, sorry! To do that, the detail you mentioned should probably be checked, and raise a warning or error, passing along BacDive's detail.

katrinleinweber commented 4 years ago

Note to self: I think this would be a good case to start learning to arrange test-download.R with a mock .Renviron file, instead of adapting the code to fit the test.

katrinleinweber commented 4 years ago

Alternatively, I could read up on the ... argument. Maybe it could be used to refactor d7a2526`s test-insertion of user & password.