Skip to content

fix: name the site user when creating or deleting datastore tables (CKAN 2.11+ activity plugin) - #341

Open
chriswydra wants to merge 1 commit into
dathere:mainfrom
manaakiwhenua:chris/site-user-context-for-activity-main
Open

chriswydra wants to merge 1 commit into
dathere:mainfrom
manaakiwhenua:chris/site-user-context-for-activity-main

Conversation

@chriswydra

Copy link
Copy Markdown

From CKAN 2.11 the activity plugin requires context["user"] on every action that records an activity, and raises otherwise. datastore_create and datastore_delete both patch the resource, and resource_delete records an activity, so on CKAN 2.11 and 2.12 with activity enabled every push fails:

ckan.logic.ValidationError: None - {'user_id': ['User not found']}
  File ".../ckanext/datastore/logic/action.py", line 208, in datastore_create
    p.toolkit.get_action('resource_patch')(
  ...
  File ".../ckanext/datapusher_plus/jobs.py", line 147, in send_resource_to_datastore
    raise utils.JobError("Error sending data to datastore ({!s}).".format(e))

The other calls in this module already build their context from get_site_user; this adds a small _site_user_context() helper and uses it for the three calls that did not. No change on CKAN 2.10, where the context user was optional.

Verified on a CKAN 2.12.0 site (activity plugin enabled): with this change a CSV upload completes and the DataStore table is created; without it the job fails as above. Follows on from #340, which covers the Python 3.14 wheel pins for the same upgrade.

From CKAN 2.11 the activity plugin requires context["user"] on every action
that records an activity. datastore_create and datastore_delete both patch
the resource and resource_delete records one, so on CKAN 2.11+ with the
activity plugin enabled every push fails with
ValidationError: {"user_id": ["User not found"]}. The other calls in this
module already use the site user; these three now do too.

@tino097 tino097 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

2 participants