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

[23.1] Remove more flushes in database operation tools #16875

Merged
merged 1 commit into from Oct 18, 2023

Conversation

mvdbeek
Copy link
Member

@mvdbeek mvdbeek commented Oct 18, 2023

We sort of rely on the dataset not being flushed yet in order to bypass the security check for tagging post job actions, so this fixes:

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
    workflow_invocation_uuid=invocation.uuid.hex,
  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
    execution_cache=execution_cache,
  File "galaxy/tools/__init__.py", line 1937, in handle_single_execution
    execution_slice,
  File "galaxy/tools/__init__.py", line 2034, in execute
    args[key] = model.User.expand_user_properties(trans.user, param.value)
  File "galaxy/tools/actions/model_operations.py", line 102, in execute
    job_callback(job)
  File "galaxy/workflow/modules.py", line 2284, in <lambda>
    complete = True
  File "galaxy/workflow/modules.py", line 2351, in _handle_post_job_actions
    self.trans.sa_session.add(pjaa)
  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 473, in execute
    cls._execute(tag_handler, job.user, dataset_assoc.dataset, tags)
  File "galaxy/job_execution/actions/post.py", line 481, in _execute
    tag_handler.add_tags_from_list(user, output, tags, flush=False)
  File "galaxy/model/tags.py", line 74, in add_tags_from_list
    return self.set_tags_from_list(user, item, new_tags_set, flush=flush)
  File "galaxy/model/tags.py", line 92, in set_tags_from_list
    self.delete_item_tags(user, item)
  File "galaxy/model/tags.py", line 165, in delete_item_tags
    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.")

(once again).

From https://sentry.galaxyproject.org/share/issue/5b44d1ec20094a2ebe8331b1ef6e58a8/

(Please replace this header with a description of your pull request. Please include BOTH what you did and why you made the changes. The "why" may simply be citing a relevant Galaxy issue.)
(If fixing a bug, please add any relevant error or traceback)
(For UI components, it is recommended to include screenshots or screencasts)

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

@github-actions github-actions bot added area/database Galaxy's database or data access layer area/tool-framework labels Oct 18, 2023
@github-actions github-actions bot added this to the 23.2 milestone Oct 18, 2023
@mvdbeek mvdbeek changed the title Remove more flushes in database operation tools [23.1] Remove more flushes in database operation tools Oct 18, 2023
We sort of rely on the dataset not being flushed yet in order to bypass
the security check for tagging post job actions, so this fixes:

```
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
    workflow_invocation_uuid=invocation.uuid.hex,
  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
    execution_cache=execution_cache,
  File "galaxy/tools/__init__.py", line 1937, in handle_single_execution
    execution_slice,
  File "galaxy/tools/__init__.py", line 2034, in execute
    args[key] = model.User.expand_user_properties(trans.user, param.value)
  File "galaxy/tools/actions/model_operations.py", line 102, in execute
    job_callback(job)
  File "galaxy/workflow/modules.py", line 2284, in <lambda>
    complete = True
  File "galaxy/workflow/modules.py", line 2351, in _handle_post_job_actions
    self.trans.sa_session.add(pjaa)
  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 473, in execute
    cls._execute(tag_handler, job.user, dataset_assoc.dataset, tags)
  File "galaxy/job_execution/actions/post.py", line 481, in _execute
    tag_handler.add_tags_from_list(user, output, tags, flush=False)
  File "galaxy/model/tags.py", line 74, in add_tags_from_list
    return self.set_tags_from_list(user, item, new_tags_set, flush=flush)
  File "galaxy/model/tags.py", line 92, in set_tags_from_list
    self.delete_item_tags(user, item)
  File "galaxy/model/tags.py", line 165, in delete_item_tags
    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.")
```
(once again).

From https://sentry.galaxyproject.org/share/issue/5b44d1ec20094a2ebe8331b1ef6e58a8/
@@ -5721,7 +5721,7 @@ def to_history_dataset_association(self, target_history, parent_id=None, add_to_
sa_session.commit()
return hda

def copy(self, parent_id=None, target_folder=None):
def copy(self, parent_id=None, target_folder=None, flush=True):
Copy link
Member

Choose a reason for hiding this comment

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

so, commit depending on the value of flush? (there are 2 unconditional commits at the end of the method)

Copy link
Member Author

Choose a reason for hiding this comment

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

They can't be eliminated, but the point is to have a uniform interface for the copy method

@mvdbeek mvdbeek merged commit b116321 into galaxyproject:release_23.1 Oct 18, 2023
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants