openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.12k stars 724 forks source link

Enterprise with empty country address #8993

Open filipefurtad0 opened 2 years ago

filipefurtad0 commented 2 years ago

Description

An enterprise with an empty country info was found during release testing; This breaks the UI and has potential to become a serious issue if occurring in production.

Seems related with this bugsnag error, from production (AU):


ActionView::Template::Errorspree/admin/orders/customer_details#update
undefined method `states' for nil:NilClass

https://app.bugsnag.com/yaycode/openfoodnetwork-aus/errors/6229aac74662e0000932c5d7

Expected Behavior

Addresses associated with enterprises must have country info.

Actual Behaviour

One address associated with one enterprise was found to have missing country info (staging-UK).

Steps to Reproduce

Could not reproduce this through the UI, so:

  1. Open the psql shell
  2. Find the id for that enterprise and the respective address_id
  3. Set the country as NULL, with
  4. UPDATE spree_addresses SET country_id = NULL where id = <>;
  5. Check the enterprise details page on the browser an notice the broken UI.

Animated Gif/Screenshot

image.png

Workaround

Manually setting it in the UI.

Severity

If really verified in production will probably disrupt quite a lot of things... Would make up for an s2 at least.

Your Environment

Possible Fix

filipefurtad0 commented 2 years ago

I've queried staging-UK and found no other enterprises with missing country info on the respective address with: SELECT id, name from enterprises where address_id = (select id from spree_addresses where country_id IS NULL);

I'll have a look in Metabase to see if this an issue in production currently.

jibees commented 2 years ago

I ran

select * from enterprises, spree_addresses where enterprises.address_id = spree_addresses.id and spree_addresses.country_id IS NULL

in prod-fr, and 0 rows returned.