From 8c3e26e0008332f75ba010cdb4850c3528d5b262 Mon Sep 17 00:00:00 2001 From: Austin Varga Date: Mon, 6 Apr 2026 17:27:47 -0600 Subject: [PATCH 1/4] fix: resolve four bugs in execution, module, context, and workflow - execution.py: use == instead of is for string module comparison (#135) - context.py: accept str in workflow_id setter by converting to UUID (#136) - module.py: use module.__name__ as sys.modules key instead of module object (#137) - workflow.py: whitelist valid execution modes before calling getattr (#138) --- dotflow/core/context.py | 2 ++ dotflow/core/execution.py | 2 +- dotflow/core/module.py | 2 +- dotflow/core/workflow.py | 9 +++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dotflow/core/context.py b/dotflow/core/context.py index 087a1d04..9053a01a 100644 --- a/dotflow/core/context.py +++ b/dotflow/core/context.py @@ -80,6 +80,8 @@ def workflow_id(self): @workflow_id.setter def workflow_id(self, value: UUID): + if isinstance(value, str): + value = UUID(value) if isinstance(value, UUID): self._workflow_id = value diff --git a/dotflow/core/execution.py b/dotflow/core/execution.py index 3eadaf00..98b46859 100644 --- a/dotflow/core/execution.py +++ b/dotflow/core/execution.py @@ -59,7 +59,7 @@ def _is_action(self, class_instance: Callable, func: Callable): return ( callable(getattr(class_instance, func)) and getattr(class_instance, func).__module__ - is Action.__module__ + == Action.__module__ and not func.startswith("__") ) except AttributeError: diff --git a/dotflow/core/module.py b/dotflow/core/module.py index 0866c16c..2297bf97 100644 --- a/dotflow/core/module.py +++ b/dotflow/core/module.py @@ -19,7 +19,7 @@ def import_module(cls, value: str): spec = file_location(value, cls._get_path(value)) module = module_from_spec(spec) - sys.modules[module] = module + sys.modules[module.__name__] = module spec.loader.exec_module(module) if hasattr(module, cls._get_name(value)): diff --git a/dotflow/core/workflow.py b/dotflow/core/workflow.py index 5e7b9bab..1764cb11 100644 --- a/dotflow/core/workflow.py +++ b/dotflow/core/workflow.py @@ -107,10 +107,11 @@ def __init__( execution = None groups = grouper(tasks=tasks) - try: - execution = getattr(self, mode) - except AttributeError as err: - raise ExecutionModeNotExist() from err + VALID_MODES = {"sequential", "sequential_group", "background", "parallel"} + if mode not in VALID_MODES: + raise ExecutionModeNotExist() + + execution = getattr(self, mode) self.tasks = execution( tasks=tasks, From 677160d8a5cf375ae67ca799a4476a03ba4f0915 Mon Sep 17 00:00:00 2001 From: Austin Varga Date: Mon, 6 Apr 2026 17:49:14 -0600 Subject: [PATCH 2/4] style: ruff format workflow.py --- dotflow/core/workflow.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dotflow/core/workflow.py b/dotflow/core/workflow.py index 1764cb11..312275ce 100644 --- a/dotflow/core/workflow.py +++ b/dotflow/core/workflow.py @@ -107,7 +107,12 @@ def __init__( execution = None groups = grouper(tasks=tasks) - VALID_MODES = {"sequential", "sequential_group", "background", "parallel"} + VALID_MODES = { + "sequential", + "sequential_group", + "background", + "parallel", + } if mode not in VALID_MODES: raise ExecutionModeNotExist() From 3c7ea9a1055c47597a43183bc270069200b46365 Mon Sep 17 00:00:00 2001 From: Austin Varga Date: Mon, 6 Apr 2026 19:08:55 -0600 Subject: [PATCH 3/4] fix: wrap UUID conversion with clear error for invalid workflow_id strings --- dotflow/core/context.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dotflow/core/context.py b/dotflow/core/context.py index 9053a01a..d8051db2 100644 --- a/dotflow/core/context.py +++ b/dotflow/core/context.py @@ -81,7 +81,12 @@ def workflow_id(self): @workflow_id.setter def workflow_id(self, value: UUID): if isinstance(value, str): - value = UUID(value) + try: + value = UUID(value) + except ValueError: + raise ValueError( + f"Invalid workflow_id: '{value}' is not a valid UUID format." + ) if isinstance(value, UUID): self._workflow_id = value From a9c5e2862f47110476ffe61090f1192c14080344 Mon Sep 17 00:00:00 2001 From: Austin Varga Date: Mon, 6 Apr 2026 19:25:26 -0600 Subject: [PATCH 4/4] fix: add 'from err' to re-raise for ruff B904 compliance --- dotflow/core/context.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dotflow/core/context.py b/dotflow/core/context.py index d8051db2..66541047 100644 --- a/dotflow/core/context.py +++ b/dotflow/core/context.py @@ -83,10 +83,10 @@ def workflow_id(self, value: UUID): if isinstance(value, str): try: value = UUID(value) - except ValueError: + except ValueError as err: raise ValueError( f"Invalid workflow_id: '{value}' is not a valid UUID format." - ) + ) from err if isinstance(value, UUID): self._workflow_id = value