ckan / ckanext-spatial

Geospatial extension for CKAN
http://docs.ckan.org/projects/ckanext-spatial
125 stars 190 forks source link

TypeError when spatial is missing #306

Closed smotornyuk closed 1 year ago

smotornyuk commented 1 year ago

Problem: There is an assumption in the code that geometry may be missing from the metadata

But code doesn't handle TypeError which is raised in this case.

Solution: Skip an attempt to parse missing geometry as a JSON value + explicitly notify user about missing geometry.

amercader commented 1 year ago

You are right, but perhaps the check needs to be made one level above, on the index_dataset() function of the different backends (in addition to the parse_geojson() one):

        geom_from_metadata = dataset_dict.get("spatial")
        if not geom_from_metadata:
             return dataset_dict
        geometry = self.parse_geojson(geom_from_metadata)

Basically I don't want to log an error for each dataset that doesn't have a spatial extra, there are plenty of instances that combine spatial and non-spatial datasets

smotornyuk commented 1 year ago

Sorry, it took me ages to change just a couple of lines:)