Skip to content

Commit bae1789

Browse files
zspencergeeksam
authored andcommitted
Document adding classes Serialized by LabTech to Psych
We've been using LabTech for about a week at one of my clients, and we had a... tiny bit of an outage because our test-cases didn't quite cover running the experiment when it was *deserializing* data. We're not sure if this is a comprehensive list of classes used by LabTech, because we had some classes already permitted (`ActiveSupport::Duration`, `Range`, and `ActiveSupport::HashWithIndifferentAccess` to be specific). Hopefully this will help other folks getting started to avoid any unpleasantness.
1 parent 1d078cd commit bae1789

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,20 @@ Copied migration 20190822175815_create_experiment_tables.lab_tech.rb from lab_te
366366

367367
Once that's done, you should be good to go! See the "Usage" section, above.
368368

369+
### Prevent `Psych::DisallowedClass` Errors
370+
371+
LabTech stores `Observation#value` as a
372+
[Rails `serialize`d field](https://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/Serialization/ClassMethods.html#method-i-serialize),
373+
which uses [Psych.safe_load](https://www.rubydoc.info/stdlib/psych/Psych.safe_load).
374+
`Psych.safe_load` raises exceptions when deserializing data of an unpermitted class.
375+
LabTech requires permitting the following classes using
376+
[config.active_record.yaml_column_permitted_classes](https://guides.rubyonrails.org/configuring.html#config-active-record-yaml-column-permitted-classes):
377+
378+
- `Symbol`
379+
- `Time`
380+
- `ActiveSupport::TimeWithZone`
381+
- `ActiveSupport::TimeZone`
382+
369383
## Contributing
370384

371385
Bug reports and pull requests are welcome on GitHub at

0 commit comments

Comments
 (0)