Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: "Action 'package_metadata_show' not found" #1

Open
kartikbha opened this issue Jan 18, 2018 · 3 comments
Open

KeyError: "Action 'package_metadata_show' not found" #1

kartikbha opened this issue Jan 18, 2018 · 3 comments

Comments

@kartikbha
Copy link

kartikbha commented Jan 18, 2018

Getting error at
Initialize metadata
metadata = toolkit.get_action('package_metadata_show')(data_dict={'id': pkg['id']})

File '/opt/ckan/ckanext/ckanext-s3-resources/ckanext/datagovsg_s3_resources/plugin.py', line 107 in after_create
self.after_create_or_update(context, resource)
File '/opt/ckan/ckanext/ckanext-s3-resources/ckanext/datagovsg_s3_resources/plugin.py', line 92 in after_create_or_update
upload.upload_resource_zipfile_to_s3(context, resource)
File '/opt/ckan/ckanext/ckanext-s3-resources/ckanext/datagovsg_s3_resources/upload.py', line 173 in upload_resource_zipfile_to_s3
'package_metadata_show')(data_dict={'id': pkg['id']})
File '/usr/lib/ckan/default/src/ckan/ckan/logic/init.py', line 377 in get_action
raise KeyError("Action '%s' not found" % action)
KeyError: "Action 'package_metadata_show' not found"

@joelchoo
Copy link
Contributor

joelchoo commented Jan 18, 2018

@kartikbha thanks for letting us know about this. package_metadata_show is a custom action that we defined to extract the metadata of the package and it's resources. It returns a dictionary of the metadata i.e. { 'organisation': 'ABC Org' }. Unfortunately our current implementation has a lot of customised metadata so it's not been open sourced yet, so your immediate options are to:

  • Change the action to package_show
  • Implement your own package_metadata_show

I'll update this issue when we've open sourced our implementation of package_metadata_show. Let me know if you need any more help with this!

@kartikbha
Copy link
Author

After changing action to package_show. I got below error.

2018-01-20 00:16:16,930 INFO [ckanext.datagovsg_s3_resources.upload] Starting upload_resource_to_s3 for resource Control Sheet.pdf
2018-01-20 00:16:16,957 INFO [ckanext.datagovsg_s3_resources.upload] File is being uploaded
2018-01-20 00:16:16,957 INFO [ckanext.datagovsg_s3_resources.upload] Uploading resource Control Sheet.pdf to S3
2018-01-20 00:16:17,087 INFO [ckanext.datagovsg_s3_resources.upload] Successfully uploaded resource Control Sheet.pdf to S3
2018-01-20 00:16:17,263 INFO [ckanext.datagovsg_s3_resources.upload] Starting upload_resource_zipfile_to_s3 for resource Control Sheet.pdf
2018-01-20 00:16:17,305 INFO [ckanext.datagovsg_s3_resources.upload] Obtaining file from URL
2018-01-20 00:16:17,862 ERROR [ckanext.datagovsg_s3_resources.upload] Error obtaining resource from the given URL. Response status code is 403
Error - <type 'exceptions.Exception'>: Error obtaining resource from the given URL. Response status code is 403

File '/usr/lib/ckan/default/lib/python2.7/site-packages/pylons/controllers/core.py', line 60 in _perform_call
return func(**args)
File '/usr/lib/ckan/default/src/ckan/ckan/controllers/package.py', line 678 in new_resource
get_action('resource_create')(context, data)
File '/usr/lib/ckan/default/src/ckan/ckan/logic/init.py', line 457 in wrapped
result = _action(context, data_dict, **kw)
File '/usr/lib/ckan/default/src/ckan/ckan/logic/action/create.py', line 345 in resource_create
plugin.after_create(context, resource)
File '/opt/ckan/ckanext/ckanext-s3-resources/ckanext/datagovsg_s3_resources/plugin.py', line 107 in after_create
self.after_create_or_update(context, resource)
File '/opt/ckan/ckanext/ckanext-s3-resources/ckanext/datagovsg_s3_resources/plugin.py', line 92 in after_create_or_update
upload.upload_resource_zipfile_to_s3(context, resource)
File '/opt/ckan/ckanext/ckanext-s3-resources/ckanext/datagovsg_s3_resources/upload.py', line 207 in upload_resource_zipfile_to_s3
raise Exception("Error obtaining resource from the given URL. Response status code is %d" % response.status_code)
Exception: Error obtaining resource from the given URL. Response status code is 403

@joelchoo
Copy link
Contributor

Can you describe the exact steps you're doing to reproduce this? Is it only for a specific resource/package or for all resources?

Also, if you can copy paste the output of package_show and resource_show for a resource/package that isn't working that would be very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants