[ckan-dev] Some default previews always created?

Matthew Fullerton matthew at smartlane.de
Fri May 8 07:29:42 UTC 2015

I'm having a weird and wonderful problem involving harvesting. I harvest 2963 datasets, and 3 of them cause an error (cryptic of course, implying that there is no name value, even though there is). After a lot of digging, I see it is because my resources (which only have one key - 'url', which is enough for a standard CKAN entry) have no name key, and this is upsetting (99% certain) the image preview when it tries to become created. These 3 datasets seem to be the only ones with .jpg resources. This is the stack trace:

Traceback (most recent call last):
  File "/usr/lib/ckan/default/src/ckanext-harvest/ckanext/harvest/harvesters/base.py", line 221, in _create_or_update_package
    new_package = get_action('package_create_rest')(context, package_dict)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/__init__.py", line 424, in wrapped
    result = _action(context, data_dict, **kw)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/action/create.py", line 1115, in package_create_rest
    dictized_after = _get_action('package_create')(context, dictized_package)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/__init__.py", line 424, in wrapped
    result = _action(context, data_dict, **kw)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/action/create.py", line 212, in package_create
    context, {'package': data})
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/__init__.py", line 424, in wrapped
    result = _action(context, data_dict, **kw)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/action/create.py", line 465, in package_create_default_resource_views
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/datapreview.py", line 303, in add_views_to_dataset_resources
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/datapreview.py", line 269, in add_views_to_resource
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/__init__.py", line 424, in wrapped
    result = _action(context, data_dict, **kw)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/action/create.py", line 363, in resource_view_create
    raise ValidationError(errors)
ValidationError: None - {'name': ['Missing value']}

However, I haven't included ANY resource views in my plugins list, and the I don't set the list of default views to create either. The docs imply that the image preview has to be added explicitly as a plugin - is this really the case?

I'm not sure if its good that resource previews are allowed to have a stricter schema for validation than that of the dataset itself, but that's a separate issue. Right now I would just like to prevent 'package_create_default_resource_views' ever getting called.

I'm on CKAN '2.4' (i.e. fairly recent master).

Thanks for any help - this is driving me slightly crackers!

More information about the ckan-dev mailing list