specify / specify7

Specify 7
https://www.specifysoftware.org/products/specify-7/
GNU General Public License v2.0
62 stars 36 forks source link

`HierarchyException` when loading Collectionreltype #4989

Open grantfitzsimmons opened 3 months ago

grantfitzsimmons commented 3 months ago

Describe the bug When displaying the collectionRelType field as a query combo box, the user is presented with the following error:

HierarchyException at /api/specify_rows/collectionreltype/ queryset model 
Collectionreltype has no hierarchy field

This leads to the form being unable to load and the user no longer being able to use the application.

image

Form XML

<cell type="field" id="collectionRelType" name="collectionRelType" uitype="querycbx" initialize="name=CollectionRelType;isrequired=true;newbtn=false;editbtn=false" isrequired="true"/>

To Reproduce Steps to reproduce the behavior:

  1. Go to https://mpabi20240604-edge.test.specifysystems.org/specify/view/collectionobject/2135/?recordsetid=41
  2. Wait for the record to load
  3. See crash

Screenshots

Left is [v7.9.3.1](https://mpabi20240604-v793.test.specifysystems.org/specify/view/collectionobject/2135/?recordsetid=41) and right is [edge](https://mpabi20240604-edge.test.specifysystems.org/specify/view/collectionobject/2135/?recordsetid=41) (during v7.9.6 testing)

image

Crash Report Specify 7 Crash Report - 2024-06-05T17_42_31.246Z.txt

Reported By University of Michigan

IMPACT: This prevents me from keeping our newest project, the MPABI [michigan pathogen] database from upgrading to the newest versions of Specify [beyond 7.9.1.1].

User reports the following: Problematic in v7.9.4 Originally working in v7.9.1.1 Tested to seemingly be working ok in v7.9.3.1 but the test was not exhaustive.

melton-jason commented 3 months ago

This issue was caused by #3304. Specifically, this happens because as of https://github.com/specify/specify7/pull/3240, the frontend overrides the CollectionRelType -> name field to be a picklist with items matching the name of CollectionRelTypes.

https://github.com/specify/specify7/blob/43c4b7484498e32521e123591794ea06b4614dc1/specifyweb/frontend/js_src/lib/components/PickLists/definitions.ts#L207-L212

When Specify is formatting the CollectionRelType, it has to fetch this frontend picklist and in this case, fetch all of the picklist items.

https://github.com/specify/specify7/blob/43c4b7484498e32521e123591794ea06b4614dc1/specifyweb/frontend/js_src/lib/components/Formatters/fieldFormat.ts#L39-L45

The picklist items for picklists based on a field are fetched via the below lines. In #3304, it was made so that Specify will always try and scope the returned results for the picklist (for example, if you define a picklist based off of CollectionObject -> catalogNumber, only the catalogNumber's for CollectionObjects in the current collection will be converted into picklist items). Previously, all picklist items for picklists of this type were unscoped.

https://github.com/specify/specify7/blob/43c4b7484498e32521e123591794ea06b4614dc1/specifyweb/frontend/js_src/lib/components/PickLists/fetch.ts#L144-L167

The issue here is that CollectionRelType can not be reliably scoped, so the backend throws the HierarchyException. See related #3564.

bronwyncombs commented 2 months ago
specifysoftware commented 2 months ago

This issue has been mentioned on Specify Community Forum. There might be relevant details there:

https://discourse.specifysoftware.org/t/error-querying-the-collection-relationship-table/1827/3

specifysoftware commented 1 month ago

This issue has been mentioned on Specify Community Forum. There might be relevant details there:

https://discourse.specifysoftware.org/t/create-a-collection-relationship-in-specify-7/1837/3

mcruz-umich commented 1 month ago

Very excited to see this get fixed so we can update to newest S7! Thanks for putting this in the 7.9.8 milestone!