From 81e9d52b4a85aff36c1a47b72e57025d2c4c8bae Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 24 Oct 2023 11:40:35 +0200 Subject: [PATCH] Fix unbound runner variable when there is an error in the job config Fixes ``` UnboundLocalError: local variable 'runner' referenced before assignment File "galaxy/jobs/handler.py", line 541, in __handle_waiting_jobs self.dispatcher.put(self.job_wrappers.pop(job.id)) File "galaxy/jobs/handler.py", line 1224, in put runner = self.get_job_runner(job_wrapper, get_task_runner=True) File "galaxy/jobs/handler.py", line 1221, in get_job_runner return runner ``` from https://sentry.galaxyproject.org/share/issue/a0a0049feb53487f9c84ede3784624b0/ which followed `(53095435) Invalid job runner: bridges`. --- lib/galaxy/jobs/handler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/galaxy/jobs/handler.py b/lib/galaxy/jobs/handler.py index e654423f2713..92beb0b4f1a0 100644 --- a/lib/galaxy/jobs/handler.py +++ b/lib/galaxy/jobs/handler.py @@ -1216,12 +1216,16 @@ def get_job_runner(self, job_wrapper, get_task_runner=False): except KeyError: log.error(f"({job_wrapper.job_id}) Invalid job runner: {runner_name}") job_wrapper.fail(DEFAULT_JOB_RUNNER_FAILURE_MESSAGE) + return None if get_task_runner and job_wrapper.can_split() and runner.runner_name != "PulsarJobRunner": return self.job_runners["tasks"] return runner def put(self, job_wrapper): runner = self.get_job_runner(job_wrapper, get_task_runner=True) + if runner is None: + # Something went wrong, we've already failed the job wrapper + return if isinstance(job_wrapper, TaskWrapper): # DBTODO Refactor log.debug(f"({job_wrapper.job_id}) Dispatching task {job_wrapper.task_id} to task runner")