Skip to content

Bug: package_revise returns a list not str in the message value on error #5888

Closed
@mcarans

Description

@mcarans

CKAN version
2.9

Describe the bug
package_revise returns a list in the message value eg.

{'message': [{'resources__1__upload': ['Unmatched key resources__1']}], '__type': 'Validation Error'}

Steps to reproduce
Specify a resource that doesn't exist when uploading eg. update__resources__1__upload

Expected behavior
Error is returned with a string message (judging by how ckanapi Python library handles the returned error message by attempting to "split" it)

Additional details
I had raised an error against the ckanapi Python library (ckan/ckanapi#186), but it seems the error is in package _revise. @wardi said "interesting, this might be a bug in package_revise, none of the other actions return a list in the message value AFAIK"

Traceback:

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'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions