From 1d684b59b4d90e83cdeea1db6f6332516ae37c18 Mon Sep 17 00:00:00 2001 From: Jason Robert Date: Fri, 6 Mar 2026 10:13:27 -0500 Subject: [PATCH] fix(engine): add `from None` to re-raised exception in except clause (B904) Ruff B904 requires explicit exception chaining when raising inside an except block. Added `from None` since we intentionally replace the ValueError/TypeError with a more descriptive ExecutionError. Also applied ruff auto-formatting fixes. Co-Authored-By: Claude Opus 4.6 --- src/conductor/engine/workflow.py | 12 +++++------- tests/test_engine/test_workflow.py | 8 ++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/conductor/engine/workflow.py b/src/conductor/engine/workflow.py index d523393..d8eb438 100644 --- a/src/conductor/engine/workflow.py +++ b/src/conductor/engine/workflow.py @@ -1948,24 +1948,22 @@ def _resolve_workflow_input_array(self, source: str, field_parts: list[str]) -> parsed = _json.loads(current) except (ValueError, TypeError): raise ExecutionError( - f"Source '{source}' resolved to a string that is not valid JSON: " - f"{current!r}", + f"Source '{source}' resolved to a string that is not valid JSON: {current!r}", suggestion="Ensure the input is a JSON array string " - "(e.g., --input items='[\"a\", \"b\"]')", - ) + '(e.g., --input items=\'["a", "b"]\')', + ) from None if not isinstance(parsed, list): raise ExecutionError( f"Source '{source}' parsed from JSON string but got " f"{type(parsed).__name__}, expected array", suggestion="Ensure the input is a JSON array " - "(e.g., --input items='[\"a\", \"b\"]')", + '(e.g., --input items=\'["a", "b"]\')', ) return parsed if not isinstance(current, (list, tuple)): raise ExecutionError( - f"Source '{source}' resolved to {type(current).__name__}, " - f"expected list or tuple", + f"Source '{source}' resolved to {type(current).__name__}, expected list or tuple", suggestion=f"Ensure '{source}' contains an array value", ) diff --git a/tests/test_engine/test_workflow.py b/tests/test_engine/test_workflow.py index bbaeb66..14843a4 100644 --- a/tests/test_engine/test_workflow.py +++ b/tests/test_engine/test_workflow.py @@ -1690,18 +1690,14 @@ def test_resolve_workflow_input_json_string_not_array( self, workflow_engine_with_context: WorkflowEngine ): """Test error when workflow input JSON string parses to non-array.""" - workflow_engine_with_context.context.set_workflow_inputs( - {"items": '{"key": "value"}'} - ) + workflow_engine_with_context.context.set_workflow_inputs({"items": '{"key": "value"}'}) with pytest.raises(ExecutionError) as exc_info: workflow_engine_with_context._resolve_array_reference("workflow.input.items") assert "parsed from JSON string but got dict" in str(exc_info.value) - def test_resolve_workflow_input_empty_array( - self, workflow_engine_with_context: WorkflowEngine - ): + def test_resolve_workflow_input_empty_array(self, workflow_engine_with_context: WorkflowEngine): """Test resolving an empty array from workflow.input.*.""" workflow_engine_with_context.context.set_workflow_inputs({"items": []})