-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
CKAN version
all
Describe the bug
using the wrong type of data for a column with the datastore raises an internal exception InvalidDataError from the API call. This exception isn't caught by the API view because it's not an expected exception type for APIs.
Steps to reproduce
create a datastore table with e.g. and int type column and pass a string that can't be parsed as an int with the API. API responds with 500 server error.
e.g.
$ ckanapi action datastore_create \
resource:'{"package_id":"an-existing-package"}' \
fields:'[{"id":"num", "type":"int"}]'
...
$ ckanapi action datastore_upsert method=insert \
resource_id=resource-id-from-above \
records:'[{"num":"notanum"}]'
...
File "/srv/app/src_extensions/ckan/ckanext/datastore/backend/postgres.py", line 1602, in upsert
upsert_data(context, data_dict)
File "/srv/app/src_extensions/ckan/ckanext/datastore/backend/postgres.py", line 1160, in upsert_data
raise InvalidDataError(
ckanext.datastore.backend.InvalidDataError: The data was invalid: invalid input syntax for type integer: "notanum"
Expected behavior
actions should raise a validation error so they can be caught by the API view and not cause a server error.
Additional details
Metadata
Metadata
Assignees
Labels
No labels