Skip to content

Commit

Permalink
Fix ItemOwnerShipException in tag removal
Browse files Browse the repository at this point in the history
This is another way to fix
https://sentry.galaxyproject.org/share/issue/8308250826df4554aa456a94b45bbe6a/:

```
ItemOwnershipException: User does not own item.
  File "galaxy/workflow/run.py", line 233, in invoke
    incomplete_or_none = self._invoke_step(workflow_invocation_step)
  File "galaxy/workflow/run.py", line 309, in _invoke_step
    incomplete_or_none = invocation_step.workflow_step.module.execute(
  File "galaxy/workflow/modules.py", line 2274, in execute
    execution_tracker = execute(
  File "galaxy/tools/execute.py", line 169, in execute
    execute_single_job(execution_slice, completed_jobs[i], skip=skip)
  File "galaxy/tools/execute.py", line 116, in execute_single_job
    job, result = tool.handle_single_execution(
  File "galaxy/tools/__init__.py", line 1957, in handle_single_execution
    raise e
  File "galaxy/tools/__init__.py", line 1937, in handle_single_execution
    rval = self.execute(
  File "galaxy/tools/__init__.py", line 2034, in execute
    return self.tool_action.execute(
  File "galaxy/tools/actions/__init__.py", line 683, in execute
    job_callback(job)
  File "galaxy/workflow/modules.py", line 2284, in <lambda>
    job_callback=lambda job: self._handle_post_job_actions(
  File "galaxy/workflow/modules.py", line 2351, in _handle_post_job_actions
    ActionBox.execute(self.trans.app, self.trans.sa_session, pja, job, replacement_dict)
  File "galaxy/job_execution/actions/post.py", line 575, in execute
    ActionBox.actions[pja.action_type].execute(
  File "galaxy/job_execution/actions/post.py", line 477, in execute
    cls._execute(tag_handler, job.user, dataset_collection_assoc.dataset_collection_instance, tags)
  File "galaxy/job_execution/actions/post.py", line 501, in _execute
    tag_handler.remove_tags_from_list(user, output, tags)
  File "galaxy/model/tags.py", line 81, in remove_tags_from_list
    return self.set_tags_from_list(user, item, tags_set, flush=flush)
  File "galaxy/model/tags.py", line 94, in set_tags_from_list
    self.apply_item_tags(user, item, unicodify(new_tags_str, "utf-8"), flush=flush)
  File "galaxy/model/tags.py", line 270, in apply_item_tags
    self.apply_item_tag(user, item, name, value, flush=flush)
  File "galaxy/model/tags.py", line 222, in apply_item_tag
    self._ensure_user_owns_item(user, item)
  File "galaxy/model/tags.py", line 193, in _ensure_user_owns_item
    raise ItemOwnershipException("User does not own item.")
```

By not flushing on tag removal the item for which tag ownership is being
checked will not have a primary id, so we know we can skip the ownership
check.
  • Loading branch information
mvdbeek committed Sep 30, 2023
1 parent 79cb585 commit 50d144f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/galaxy/job_execution/actions/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class RemoveTagDatasetAction(TagDatasetAction):

@classmethod
def _execute(cls, tag_handler, user, output, tags):
tag_handler.remove_tags_from_list(user, output, tags)
tag_handler.remove_tags_from_list(user, output, tags, flush=False)


class ActionBox:
Expand Down

0 comments on commit 50d144f

Please sign in to comment.