opensupplyhub / open-apparel-registry

An application for searching, matching, uploading factories.
MIT License
32 stars 13 forks source link

Error when attempting to split out an incorrect facility match #746

Open katieashaw opened 5 years ago

katieashaw commented 5 years ago

Overview

When attempting to split out an incorrect facility match, I am receiving an error message. This is despite having split off other incorrect matches on the same facility.

Expected Behavior

The incorrect match should create a new facility when "Split" is selected.

Actual Behavior

An error message appears:

Screenshot 2019-08-22 at 17 30 34

Steps to Reproduce

Additional context

Match numbers 6896 and 15409 were both successfully split off.

jwalgran commented 5 years ago

Rollbar log of the error: https://rollbar.com/OpenApparelRegistry/OpenApparelRegistry/items/224/

rajadain commented 5 years ago

The OAR ID the issue originally referenced isn't searchable in the production UI. We do see this though:

SELECT * FROM api_facilityalias WHERE oar_id = 'BD20190833PDBEW';

     oar_id      | reason |          created_at           |          updated_at           |   facility_id
-----------------+--------+-------------------------------+-------------------------------+-----------------
 BD20190833PDBEW | MERGE  | 2019-09-02 16:51:34.317508+00 | 2019-09-02 16:51:34.317523+00 | BD2019234J71EWZ
rajadain commented 5 years ago

This is the top-level facility on production corresponding to the one mentioned above: https://openapparel.org/facilities/BD2019234J71EWZ

rajadain commented 5 years ago

Just looked at the history of the related facilities with @jwalgran:

SELECT * FROM api_historicalfacility WHERE LOWER(name) LIKE 'fakir fashion%' ORDER BY history_date;

       id        |       name        |                                address                                 | country_code |                      location                      |          created_at           |          updated_at           | history_id |         history_date          |    history_change_reason    | history_type | created_from_id | history_user_id
-----------------+-------------------+------------------------------------------------------------------------+--------------+----------------------------------------------------+-------------------------------+-------------------------------+------------+-------------------------------+-----------------------------+--------------+-----------------+-----------------
 BD20190833PDBEW | Fakir fashion ltd | Dohorgaon Post Office, Balia Para 1460 Rupgonj Narayanganj Narayanganj | BD           | 0101000020E6100000423B4CA0ADA156408A0B9B5CE7C63740 | 2019-03-24 03:48:48.234871+00 | 2019-03-24 03:48:48.234884+00 |       1830 | 2019-05-20 16:57:46.876133+00 |                             | +            |            1912 |
 BD2019176ZA0Q22 | Fakir Fashion Ltd | Dohorgaon Road Narayangonj  1460                                       | BD           | 0101000020E6100000CE9662FDD59F56407D7E73DAAEA13740 | 2019-06-25 13:50:38.49862+00  | 2019-06-25 13:50:38.498643+00 |      16127 | 2019-06-25 13:50:38.499359+00 |                             | +            |           23627 |             140
 BD2019234YTPXDK | Fakir Fashion Ltd | Dohorgaon Road, 1460, Narayangonj, Bangladesh                          | BD           | 0101000020E610000043A852B387A65640E55A5947FAA73740 | 2019-08-22 16:28:36.529933+00 | 2019-08-22 16:28:36.529953+00 |      18930 | 2019-08-22 16:28:36.530746+00 |                             | +            |            7827 |              74
 BD2019234J71EWZ | Fakir Fashion Ltd | Dohorgaon Road, 1460, Narayangonj, Bangladesh                          | BD           | 0101000020E610000043A852B387A65640E55A5947FAA73740 | 2019-08-22 16:29:25.293046+00 | 2019-08-22 16:29:25.293066+00 |      18931 | 2019-08-22 16:29:25.294191+00 |                             | +            |           15088 |              74
 BD2019234YTPXDK | Fakir Fashion Ltd | Dohorgaon Road, 1460, Narayangonj, Bangladesh                          | BD           | 0101000020E610000043A852B387A65640E55A5947FAA73740 | 2019-08-22 16:28:36.529933+00 | 2019-08-22 16:28:36.529953+00 |      18932 | 2019-08-22 16:49:58.821519+00 | Merged with BD2019234J71EWZ | -            |            7827 |              74
 BD2019176ZA0Q22 | Fakir Fashion Ltd | Dohorgaon Road Narayangonj  1460                                       | BD           | 0101000020E6100000CE9662FDD59F56407D7E73DAAEA13740 | 2019-06-25 13:50:38.49862+00  | 2019-06-25 13:50:38.498643+00 |      18933 | 2019-08-22 16:50:17.872903+00 | Merged with BD2019234J71EWZ | -            |           23627 |              74
 BD20190833PDBEW | Fakir fashion ltd | Dohorgaon Post Office, Balia Para 1460 Rupgonj Narayanganj Narayanganj | BD           | 0101000020E6100000423B4CA0ADA156408A0B9B5CE7C63740 | 2019-03-24 03:48:48.234871+00 | 2019-03-24 03:48:48.234884+00 |      19579 | 2019-09-02 16:51:34.323424+00 | Merged with BD2019234J71EWZ | -            |            1912 |              74

It seems like all the relevant facilities were successfully merged with BD2019234J71EWZ. Because the data is changed, we are unable to recreate the exact conditions under which the problem occurred. We are also unable to independently create conditions where this may have happened.

We evaluated if a facility list uploaded multiple times would cause this, or if clicking the Split button multiple times would do it, but were unable to verify any hypothesis.

As such, I think we should pause work on this until its priority and relevance has been reaffirmed.

katieashaw commented 5 years ago

Confirming @jwalgran that I've looked into this on the Moderation Log: https://docs.google.com/spreadsheets/d/16wbgJF2mqYo4SfDH4YkohPgufpvNyNuA_OU2cW_bTgI/edit#gid=0

If you look at entries #25 and #26, whatever the error was clearly resolved itself and I was able to split out the problematic entry, then merge it back with others.

jwalgran commented 5 years ago

Thank you for the confirmation, Katie. If you run into this again we will reopen the issue and take another look.

jwalgran commented 5 years ago

Katie just ran into an error while splitting a facility

IntegrityError:
null value in column "location" violates not-null constraint

https://rollbar.com/OpenApparelRegistry/OpenApparelRegistry/items/224/

Attempting to split this facility

Screenshot 2019-09-30 at 17 02 23

Error message shown

Screenshot 2019-09-30 at 17 02 06

jwalgran commented 5 years ago

Looks like the problem there is that the geocoder did not return coordinates for that item when it was originally processed, but it was a potential match to another facility. The split is failing because we are trying to create a new facility without a location.

We have a couple options in this case.

In addition, this item is also in the POTENTIAL_MATCH status. We should not show "SPLIT" or "PROMOTE" buttons if the match is PENDING.

jwalgran commented 5 years ago

I cleared the assignment because it was left over from the first time this issue was reviewed. It may end up being handled by someone else on the team.