archesproject / arches

Arches is a web platform for creating, managing, & visualizing geospatial data. Arches was inspired by the needs of the Cultural Heritage community, particularly the widespread need of organizations to build & manage cultural heritage inventories
GNU Affero General Public License v3.0
211 stars 140 forks source link

CSV export issues when exporting in card order #11008

Open bferguso opened 1 month ago

bferguso commented 1 month ago

When exporting CSV in card order, if a card does not have a sort order it is silently ignored even if nodes on that card are marked for export. This results in the headers not being exported for those nodes, however the search_export.py tries to export the data for those nodes causing an exception on line 353 in /arches/app/search/search_export.py caused by line 149 in csv.py: raise ValueError("dict contains fields not in fieldnames:.

The headers of the nodes are not exported due to the except part of the following line in search_export.py: 81 all_card_list_with_sort = list(all_cards.exclude(sortorder=None).order_by("sortorder"))

I believe the above was added to avoid a cannot compare with NoneType (yes, paraphrased) exception when sorting the cards.

I think there should be a larger conversation about whether all cards (and all widgets) in a graph should have a sortorder value or not. This number is not directly manipulated by the user, it is maintained by the system by dragging the nodes in the graph manager. Because the sort order values are maintained by the system it seems like a reasonable expectation for all nodes and all cards to have a sortorder value.

jacobtylerwalls commented 1 month ago

Because the sort order values are maintained by the system it seems like a reasonable expectation for all nodes and all cards to have a sortorder value.

Yeah, I think we desperately need to make sortorder not nullable in lots of places.