ckan / ckanapi

A command line interface and Python module for accessing the CKAN Action API
Other
181 stars 74 forks source link

Bug: Error message processing fails with package_revise #186

Closed mcarans closed 3 years ago

mcarans commented 3 years ago

If I specify an incorrect resource eg. update__resources__1__upload when there is only one resource, the error message processing in common.py fails with this error:

'list' object has no attribute 'split'

on this line:

emessage = err.get('message', '').split(': ', 1)[-1]

When the failure occurs "err" is:

{'message': [{'resources__1__upload': ['Unmatched key resources__1']}], '__type': 'Validation Error'}
wardi commented 3 years ago

Please post the full traceback

mcarans commented 3 years ago
Traceback (most recent call last):
  File "/home/mcarans/Programming/hdx-python-api/src/hdx/data/hdxobject.py", line 331, in _write_to_hdx
    return self.configuration.call_remoteckan(self.actions()[action], data, files=files_to_upload)
  File "/home/mcarans/Programming/hdx-python-api/src/hdx/hdx_configuration.py", line 307, in call_remoteckan
    return self.remoteckan().call_action(*args, **kwargs)
  File "/home/mcarans/Programming/VirtualEnvs/hdx-python-api/lib/python3.8/site-packages/ckanapi/remoteckan.py", line 88, in call_action
    return reverse_apicontroller_action(url, status, response)
  File "/home/mcarans/Programming/VirtualEnvs/hdx-python-api/lib/python3.8/site-packages/ckanapi/common.py", line 114, in reverse_apicontroller_action
    emessage = err.get('message', '').split(': ', 1)[-1]
AttributeError: 'list' object has no attribute 'split'
wardi commented 3 years ago

Thanks. What's the contents of err when this happens?

mcarans commented 3 years ago
{'message': [{'resources__1__upload': ['Unmatched key resources__1']}], '__type': 'Validation Error'}
wardi commented 3 years ago

interesting, this might be a bug in package_revise, none of the other actions return a list in the message value AFAIK

mcarans commented 3 years ago

Do you need me to raise this in the GitHub CKAN project?

wardi commented 3 years ago

sure but it's worth fixing in ckanapi too, ckanapi shouldn't fail if it gets something it's not expecting here