mountetna / magma

Data server with friendly data loaders
GNU General Public License v2.0
5 stars 2 forks source link

Only privileged users can load table data #205

Open coleshaw opened 3 years ago

coleshaw commented 3 years ago

Because of how censor revisions works in combination with the table temporary IDs, only a project's privileged users can upload table data. Not sure if this counts as a bug, or we'll just have to give all the data scientists the privileged flag (might be super difficult to work around).

You get this error thrown (relevant parts):

ERROR:2020-12-11T17:18:15-08:00 ee6xwh Caught unspecified error
ERROR:2020-12-11T17:18:15-08:00 ee6xwh PG::InvalidTextRepresentation: ERROR:  invalid input syntax for integer: "::demographic1"
LINE 1: ...ics" AS "liqajteise" WHERE ("liqajteise"."id" IN ('::demogra...
                                                             ^
ERROR:2020-12-11T17:18:15-08:00 ee6xwh magma/query/query_executor.rb:12:in `execute'
ERROR:2020-12-11T17:18:15-08:00 ee6xwh magma/query/question.rb:112:in `to_table'
ERROR:2020-12-11T17:18:15-08:00 ee6xwh magma/query/question.rb:66:in `answer'
ERROR:2020-12-11T17:18:15-08:00 ee6xwh magma/censor.rb:24:in `censored_reasons'
ERROR:2020-12-11T17:18:15-08:00 ee6xwh magma/loader.rb:335:in `block in censor_revisions!'
ERROR:2020-12-11T17:18:15-08:00 ee6xwh magma/loader.rb:334:in `each'
ERROR:2020-12-11T17:18:15-08:00 ee6xwh magma/loader.rb:334:in `censor_revisions!'
ERROR:2020-12-11T17:18:15-08:00 ee6xwh magma/loader.rb:251:in `dispatch_record_set'
ERROR:2020-12-11T17:18:15-08:00 ee6xwh magma/server/update.rb:29:in `load_revisions'
ERROR:2020-12-11T17:18:15-08:00 ee6xwh magma/server/update.rb:8:in `action'

Because the censor uses the revision's IDs to check for restricted access, but a table revision only has temporary IDs, the query breaks and dies. The workaround is to make sure the user is a privileged user that can see and edit restricted records.