diff --git a/workflows/tests/test_variable_utils_yaml.py b/workflows/tests/test_variable_utils_yaml.py new file mode 100644 index 0000000..e79f003 --- /dev/null +++ b/workflows/tests/test_variable_utils_yaml.py @@ -0,0 +1,19 @@ +"""Test that process_workflow_file_with_markers handles YAML workflow files.""" + +import json +from pathlib import Path + +import pytest + +from workflow_use.healing.variable_utils import process_workflow_file_with_markers + +_FIXTURE = Path(__file__).parent / 'test_go_back.workflow.yaml' + + +def test_process_yaml_workflow_does_not_raise(tmp_path): + """YAML workflow files must be parsed without JSONDecodeError.""" + output_file = tmp_path / 'output.json' + result = process_workflow_file_with_markers(_FIXTURE, output_path=output_file) + assert output_file.exists() + data = json.loads(output_file.read_text()) + assert data['name'] == 'Test Go Back' diff --git a/workflows/workflow_use/healing/variable_utils.py b/workflows/workflow_use/healing/variable_utils.py index 298f545..647408e 100644 --- a/workflows/workflow_use/healing/variable_utils.py +++ b/workflows/workflow_use/healing/variable_utils.py @@ -4,6 +4,8 @@ from pathlib import Path from typing import Optional +import yaml + from workflow_use.healing.variable_extractor import VariableExtractor from workflow_use.schema.views import WorkflowDefinitionSchema @@ -57,9 +59,12 @@ def process_workflow_file_with_markers( input_path = Path(input_path) output_path = Path(output_path) if output_path else input_path - # Load the workflow + # Load the workflow — storage service persists as YAML; fall back to JSON with open(input_path, 'r') as f: - workflow_data = json.load(f) + if input_path.suffix in {'.yaml', '.yml'}: + workflow_data = yaml.safe_load(f) + else: + workflow_data = json.load(f) workflow = WorkflowDefinitionSchema(**workflow_data)