ckanext-spatial
ckanext-spatial copied to clipboard
CSW client code fails to process MI_Metadata
Attempting to harvest from a CSW with ISO metadata starting with MI_Metadata
, rather than MD_Metadata
fails:
https://github.com/ckan/ckanext-spatial/blob/master/ckanext/spatial/lib/csw_client.py#L178-L189
Essentially, the call to .find
does not find MD_Metadata
, and so returns None
, which gets propagated down to this line:
record["xml"] = '<?xml version="1.0" encoding="UTF-8"?>\n' + record["xml"]
This raises an exception since concatenating a string with None
is not a valid operation. This could be fairly easily fixed by adding in the MI_Metadata
as a valid element to find as well.
In fact, it looks like the data.gov fork of ckanext-spatial does just that:
https://github.com/GSA/ckanext-spatial/blob/datagov/ckanext/spatial/lib/csw_client.py#L171
Additionally, cases in which root elements which weren't MD_Metadata
or MI_Metadata
should be handled early so that a sane error message is raised, rather than an error about concatenating string to None, which does not make the reason for failure particularly clear .
Related #210