CSW client code fails to process MI_Metadata
- Dominant language
- XSLT
- Stars
- 136
- Forks
- 207
- PR merge metrics
- No merged PRs in 30d
Description
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:
```python
record["xml"] = '\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 .
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in ckanext/spatial/lib/csw_client.py around lines 178-189 and reproduce harvesting with an ISO record whose root is MI_Metadata. Ensure both supported metadata roots are processed and unsupported roots produce a clear error before XML concatenation; verify that the harvest no longer fails with a string-and-None exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100