developmentseed / tecnico-energy-app

https://dashboard-ds-peach.vercel.app/
0 stars 0 forks source link

Need to better handle situations where a metrics_metadata record references a non-existent field #39

Open alukach opened 3 months ago

alukach commented 3 months ago

Currently, if a field is referenced in the metrics_metadata sheet that does not exist in the metrics sheet, a vague error will be thrown during ingestion at our aggregation stage:

ERROR:  cannot cast jsonb null to type numeric`

This occurs because we attempt to retrieve the value at the incorrect field location and instead retrieve null, which can not be turned into a number:

https://github.com/developmentseed/tecnico-energy-app/blob/995ea5d83313b94d8ef26a2d86f82e950f883240/prisma/migrations/20240313042750_add_functions/migration.sql#L101

We should either gracefully handle and ignore these incorrect fields or throw a more explicit error.