Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/conductor/engine/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Expand Down
8 changes: 2 additions & 6 deletions tests/test_engine/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": []})

Expand Down
Loading