ckan / ckan

CKAN is an open-source DMS (data management system) for powering data hubs and data portals. CKAN makes it easy to publish, share and use data. It powers catalog.data.gov, open.canada.ca/data, data.humdata.org among many other sites.
https://ckan.org/
Other
4.38k stars 1.97k forks source link

error creating resources via GUI in 2.10 #7873

Closed millingw closed 9 months ago

millingw commented 10 months ago

CKAN version

2.10

Describe the bug

I'm using CKAN 2.10 with a custom schema (attached) defined using the ckanext-scheming extension. Creating datasets and resources via the action api with a REST client works without any issues. However, trying to add new resources via the CKAN GUI, or edit existing resources, results in an error. I'm pretty sure we didn't see this happen with 2.9.

Traceback (most recent call last):
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/werkzeug/datastructures.py", line 3042, in __getattr__
    return getattr(self.stream, name)
AttributeError: 'SpooledTemporaryFile' object has no attribute 'values'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/flask/views.py", line 158, in dispatch_request
    return current_app.ensure_sync(meth)(*args, **kwargs)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware/../../views/resource.py", line 192, in post
    data.update(clean_dict(
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/__init__.py", line 235, in clean_dict
    if not any(inner_dict.values()):
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/werkzeug/datastructures.py", line 3048, in __getattr__
    return getattr(self.stream._file, name)
AttributeError: '_io.BytesIO' object has no attribute 'values'

Digging around, I see the following in views.py at line 192 which is where the crash appears to be:

data.update(clean_dict( dict_fns.unflatten(tuplize_dict(parse_params(request.files))) ))

When we create resources, we don't upload any files with the resource. Instead, we have links to external storage systems.

eidf-dcat-ap.json

Steps to reproduce

With custom schema and ckanext-scheming installed, trying to add or edit a resource results in above error

Expected behavior

A clear and concise description of what you expected to happen.

Additional details

If possible, please provide the full stack trace of the error raised, or add screenshots to help explain your problem.

millingw commented 9 months ago

Actually, this is not a bug - please ignore and close. We were incorrectly using the resource_url_upload preset from ckanext-scheming to represent an external url, but what this actually does is generate a file upload form, whereas we just wanted to enter a url as text.

amercader commented 9 months ago

Glad you figured it out @millingw