MarkEdmondson1234 / googleAuthR

Google API Client Library for R. Easy authentication and help to build Google API R libraries with OAuth2. Shiny compatible.
https://code.markedmondson.me/googleAuthR
Other
175 stars 51 forks source link

API error with date format for gar_api_generator #155

Closed caewok closed 5 years ago

caewok commented 5 years ago

What goes wrong

Calling gce_vm_delete or gce_vm_stop (googleComputerEngineR package) throws an error:

Request Status Code: 400
Error: API returned: Invalid value '2019-08-30T12:00:51.270-07:00'. Values must match the following regular expression: '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?|[1-9][0-9]{0,19}'

(The date/time here appears to be the current date/time. The problem seems to be the "T" in the date/time string.) Using R 3.6.1 in Rstudio on Debian Linux.

I am posting here because I tracked the error down to the underlying function, googleAuthR::gar_api_generator, but I cannot figure out where the date/time parsing error originates within that function.

Steps to reproduce the problem

Start a vm: vm <- gce_vm("vm-ssh")

Stop vm: gce_vm_stop(vm)

Or delete vm: gce_vm_delete(vm)

Expected output

No error

Actual output

Request Status Code: 400
Error: API returned: Invalid value '2019-08-30T12:00:51.270-07:00'. Values must match the following regular expression: '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?|[1-9][0-9]{0,19}'

Note that the vm does stop or is deleted, depending on the function called, despite the error.

Before you run your code, please run:

options(googleAuthR.verbose=2) and copy-paste the console output here.
Check it doesn't include any sensitive info like auth tokens or accountIds - you can usually just edit those out manually and replace with say XXX

No output

Session Info

Please run sessionInfo() so we can check what versions of packages you have installed attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] googleComputeEngineR_0.3.0 googleCloudStorageR_0.5.0.9000

loaded via a namespace (and not attached): [1] zip_2.0.3 Rcpp_1.0.2 compiler_3.6.1 googleAuthR_1.0.0 prettyunits_1.0.2 [6] remotes_2.1.0 tools_3.6.1 testthat_2.2.1 digest_0.6.20 packrat_0.5.0
[11] pkgbuild_1.0.3 pkgload_1.0.2 jsonlite_1.6 memoise_1.1.0 gargle_0.3.1
[16] rlang_0.4.0 cli_1.1.0 rstudioapi_0.10 parallel_3.6.1 curl_4.0
[21] yaml_2.2.0 withr_2.1.2 httr_1.4.0 globals_0.12.4 desc_1.2.0
[26] fs_1.3.1 askpass_1.1 devtools_2.1.0 rprojroot_1.3-2 glue_1.3.1
[31] listenv_0.7.0 R6_2.4.0 processx_3.4.1 sessioninfo_1.1.1 callr_3.3.1
[36] magrittr_1.5 codetools_0.2-16 backports_1.1.4 ps_1.3.0 usethis_1.5.1
[41] assertthat_0.2.1 future_1.14.0 mime_0.7 openssl_1.4.1 crayon_1.3.4

Transferred to https://github.com/cloudyr/googleComputeEngineR/issues/144

MarkEdmondson1234 commented 5 years ago

Thanks, this should go on googleComputeEngineR issues as it will be an issue with the parse function. Will transfer it across.