ElixirTeSS / TeSS

Training e-Support Service using Ruby on Rails.
Other
12 stars 12 forks source link

`source.test_results` fails due to unpermitted `Icalendar::Values::DateTime` #986

Closed cwant closed 2 months ago

cwant commented 2 months ago

Describe the bug

I try to test ingestion with a source of type Ical, and I get:

Exception: Psych::DisallowedClass: Tried to load unspecified class: Icalendar::Values::DateTime

To Reproduce

Steps to reproduce the behavior (which work on my machine, hopefully yours too):

  1. Create a source with type Ical
  2. Click on 'test'
  3. The page says that it can't render the results
  4. Go to the console and do something like source = Source.last; source.test_results to debug.

Expected behavior

Hopefully not an error (I'm new to this so still figuring out what things are supposed to do).

Additional context

Working with docker-compose in development (rails version 7.0.8.1, ruby 3.2.2). The following change moves it further (the order here seems important, or else it has issues with DateTime):

diff --git a/config/application.rb b/config/application.rb
index 4c310e4b..a4eefa10 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -35,7 +35,8 @@ module TeSS

     config.active_record.yaml_column_permitted_classes = [
       Symbol, Date, Time, ActiveSupport::TimeWithZone, ActiveSupport::TimeZone,
-      ActiveSupport::HashWithIndifferentAccess, BigDecimal
+      ActiveSupport::HashWithIndifferentAccess, BigDecimal, DateTime,
+      Icalendar::Values::DateTime
     ]

     config.exceptions_app = self.routes

I'm not sure if this is the way to go (or if this is a problem due to my set up), but the read in test events say Errors: Timezone not found and cannot be linked to a valid timezone when I do this, so I don't know if this is just a partial solution.

Cheers, Chris

fbacall commented 2 months ago

Thanks for flagging this, I think the solution would be to convert the Icalendar::Values::DateTime into one of the permitted Date types. I'll look into it

cwant commented 2 months ago

Thanks! By the way, the timezone issues (Errors: Timezone not found and cannot be linked to a valid timezone) turned out to be our fault (the provider). We have Americas/Toronto in the input instead of Eastern Time (US & Canada). Americas/Toronto isn't known by ActiveSupport::TimeZone::MAPPING.