mountetna / magma

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

Strict mode with etna gem causes exception on update #206

Open coleshaw opened 3 years ago

coleshaw commented 3 years ago

May be related to #202, but it seems like updating certain types of attributes with null leads to an issue with temporary IDs.

When updating a bunch of clinical data via the etna gem, using strict mode leads to a Magma error:

ERROR:2021-03-10T20:48:11+00:00 9hdp4p Caught unspecified error
ERROR:2021-03-10T20:48:11+00:00 9hdp4p undefined method `real_id' for nil:NilClass
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/loader/temp_id.rb:14:in `real_id'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/loader/record_entry.rb:107:in `block in temp_entry'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/loader/record_entry.rb:104:in `each'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/loader/record_entry.rb:104:in `map'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/loader/record_entry.rb:104:in `temp_entry'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/loader.rb:427:in `map'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/loader.rb:427:in `block in update_temp_ids'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/loader.rb:423:in `each'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/loader.rb:423:in `update_temp_ids'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/loader.rb:257:in `dispatch_record_set'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/server/update.rb:29:in `load_revisions'
ERROR:2021-03-10T20:48:11+00:00 9hdp4p /app/lib/magma/server/update.rb:8:in `action'

It's not clear under what conditions this happens yet, except we know that disabling strict mode works. So I suspect that one of the null values introduced by strict mode leads to the situation where Magma thinks there is a temporary ID somewhere? Or perhaps trying to set "empty" on a parent model causes the above? Need to investigate.