molgenis / molgenis-r-datashield

Armadillo implementation of DSI to be DataSHIELD ready, part of the MOLGENIS suite
https://molgenis.github.io/molgenis-r-datashield/
0 stars 3 forks source link

When using Armadillo, `datashield.assign` does not return an error when attempting to assign a table that does not exist, if an object with the same name as 'symbol' already exists in the R environment #71

Open timcadman opened 8 months ago

timcadman commented 8 months ago

If start a fresh session and try to assign a table where the object specified in 'value' does not exist, an error is returned as expected:

datashield.assign(
  conns = conns["bib"], 
  symbol = "non_rep", 
  value = "sp455/2_5_core_1_7/asdasdasdasdasdasd")

Error: There are some DataSHIELD errors, list them with datashield.errors()

datashield.errors()

$bib [1] "$ operator is invalid for atomic vectors"

This error could be more informative, but at least there is an error.

However if we first assign the table correctly (so that an object is created in the R environment) but then try again with a non-existent table name, no error is returned, and the existing table is not overwritten.

datashield.assign(
  conns = conns["bib"], 
  symbol = "non_rep", 
  value = "sp455/2_5_core_1_7/non_rep")

Assigned all table (non_rep <- ...) [==================================================] 100% / 0s

datashield.assign(
  conns = conns["bib"], 
  symbol = "non_rep", 
  value = "sp455/asdasdasdasd/non_rep")

Assigned all table (non_rep <- ...) [==================================================] 100% / 0s

Note however that the correct error is returned if the format of the table name is not respected:

datashield.assign(
  conns = conns["bib"], 
  symbol = "non_rep", 
  value = "sdfsdfsdfsdfsdf")

Error: There are some DataSHIELD errors, list them with datashield.errors()

datashield.errors $bib [1] "Internal server error: loadTable.table: must match \"^([a-z0-9-]{0,55}[a-z0-9])/([\w-:]+)/([\w-:]+)$\""

I was expecting that an error is always returned when trying to assign a table that does not exist.