Error "unauthorized" in avtable_import
Entering edit mode
Last seen 14 hours ago
University of Washington

I'm trying to use the AnVIL package to create a data table on AnVIL. Inside a Jupyter R notebook, I can successfully browse existing tables and copy files from my workspace to the persistent storage.

A tibble: 1 × 3
table   count   colnames
<chr>   <int>   <chr>
BigQuery_table  2   BigQuery_table_id, dataset_name, table_name

When I try to use avtable_import, I get an error:

A tibble: 6 × 3
sample_id   Population  sex
<chr>   <chr>   <chr>
HG00110 GBR F
HG00116 GBR M
HG00120 GBR F
HG00128 GBR F
HG00136 GBR M
HG00137 GBR F

avtable_import(samples, entity="sample_id")
Error: 'avtable_import' failed:
  Unauthorized (HTTP 401).

1. avtable_import(samples, entity = "sample_id")
2. .avstop_for_status(response, "avtable_import")
3. stop(message, call. = FALSE)

I was able to create an identical table by writing samples to a TSV file and importing it manually, so it's not that I don't have permission to create a table in the workspace.

sessionInfo( )

R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/
LAPACK: /usr/lib/x86_64-linux-gnu/

 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            

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

other attached packages:
[1] AnVIL_1.4.1 dplyr_1.0.7

loaded via a namespace (and not attached):
 [1] pillar_1.6.2         compiler_4.1.1       BiocManager_1.30.16 
 [4] formatR_1.11         futile.logger_1.4.3  base64enc_0.1-3     
 [7] futile.options_1.0.1 tools_4.1.1          digest_0.6.27       
[10] uuid_0.1-4           jsonlite_1.7.2       evaluate_0.14       
[13] lifecycle_1.0.0      tibble_3.1.4         pkgconfig_2.0.3     
[16] rlang_0.4.11         IRdisplay_1.0        DBI_1.1.1           
[19] curl_4.3.2           IRkernel_1.2         yaml_2.2.1          
[22] fastmap_1.1.0        repr_1.1.3           httr_1.4.2          
[25] generics_0.1.0       vctrs_0.3.8          tidyselect_1.1.1    
[28] glue_1.4.2           R6_2.5.1             fansi_0.5.0         
[31] pbdZMQ_0.3-5         tidyr_1.1.3          purrr_0.3.4         
[34] lambda.r_1.2.4       magrittr_2.0.1       ellipsis_0.3.2      
[37] htmltools_0.5.2      rapiclient_0.1.3     assertthat_0.2.1    
[40] mime_0.11            utf8_1.2.2           crayon_1.4.1
AnVIL • 212 views
Entering edit mode

Hi Stephanie -- glad to see you using the AnVIL package, and AnVIL! I'm not able to log in to AnVIL at the moment due to this , but will try to investigate once the issue is resolved. In the mean time you might try updating the AnVIL package to the 'devel' version BiocManager::install("Bioconductor/AnVIL") , and also walking through the top-level function debug(avtable_import) (launch a shell in AnVIL, and start R for an interactive session) and guessing whether things are making sense, especially the values at the line response <- Terra()$flexibleImportEntities(namespace, name, entities). Also, I'm assuming you're using this within the AnVIL workspace that contains the table (you can do other more complicated things, like accessing one workspace from another, and accessing AnVIL from the desktop, as mentioned in the Quick Start portion of the Introduction to AnVIL vignettte).

Entering edit mode

Hmm, I'm not sure what the problem is. For instance in a workspace I own and through an (R-based) Jupyter notebook, I can do

avtables()  # nothing
as_tibble(mtcars, rownames = "brand_id") |>
    mutate(brand_id = make.names(brand_id)) |>
avtables() # 'brand'

If I try to access a workspace I don't have permissions for, I get a 403 error, rather than the 401 that you saw...

as_tibble(mtcars, rownames = "brand_id") |>
    mutate(brand_id = make.names(brand_id)) |>
## Error: 'avtable_import' failed:
##   Forbidden (HTTP 403).
##   insufficient permissions to perform operation on anvil-datastorage/1000G-high-coverage-2019
## Traceback:
## 1. avtable_import(mutate(as_tibble(mtcars, rownames = "brand_id"), 
##  .     brand_id = make.names(brand_id)))
## 2. .avstop_for_status(response, "avtable_import")
## 3. stop(message, call. = FALSE)

so I'm a little stymied... Does

    avtable_import(samples, entity="sample_id")

produce anything useful in the response portion? For instance, I see

<- HTTP/1.1 200 OK
<- Date: Tue, 16 Nov 2021 20:05:17 GMT
<- Server: akka-http/10.2.4
<- X-Frame-Options: SAMEORIGIN
<- X-XSS-Protection: 1; mode=block
<- X-Content-Type-Options: nosniff
<- Strict-Transport-Security: max-age=31536000; includeSubDomains
<- Access-Control-Allow-Origin: *
<- Access-Control-Allow-Headers: authorization,content-type,accept,origin,x-app-id
<- Access-Control-Max-Age: 1728000
<- Content-Type: text/plain; charset=UTF-8
<- Content-Length: 5
<- Via: 1.1 google
<- Alt-Svc: clear

(be sure to remove any Authorization: fields from what you post here...) Also, was your session active for an hour or more? Access tokens expire, but the AnVIL package is supposed to generate new ones...)

Entering edit mode

I tried running the exact same code today and it worked, so maybe my error was due to the previously mentioned AnVIL service incident. Whatever it was, it seems to be resolved now. Thanks for your help!


Login before adding your answer.

Traffic: 381 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6