fablabbcn / smartcitizen-api

The Smart Citizen Engine
https://developer.smartcitizen.me
GNU Affero General Public License v3.0
10 stars 4 forks source link

ArgumentError when devices pass spurious datetimes #273

Closed sentry-io[bot] closed 4 months ago

sentry-io[bot] commented 8 months ago

From Sentry Issue: SC-API-BZ

ArgumentError: argument out of range
  app/models/concerns/data_parser/storer.rb:44:in `timestamp_parse'
    parsed_ts = Time.parse(timestamp)
  app/models/concerns/data_parser/storer.rb:11:in `parse_reading'
    parsed_ts = timestamp_parse(reading['recorded_at'])
  app/models/storer.rb:7:in `initialize'
    parsed_reading = Storer.parse_reading(@device, reading)
  app/lib/mqtt_messages_handler.rb:52:in `new'
    Storer.new(device, reading)
  app/lib/mqtt_messages_handler.rb:52:in `block in handle_readings'
    Storer.new(device, reading)
...
(54 additional frame(s) were not displayed)

This happens when a device passes an invalid timestamp (in this case 20-30-07-13T10:09:01Z). I was going to silently catch and warn on these, but it looks like our tests for the storer explicitly assert that we raise on invalid data. Is this desirable? I'm thinking perhaps that 'devices sending dodgy data' should be handled differently. CC @oscgonfer @pral2a

oscgonfer commented 4 months ago

I think this can be closed, right @timcowlishaw ?

timcowlishaw commented 4 months ago

i think so!