Skip to content
Open
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
19 changes: 19 additions & 0 deletions workflows/tests/test_variable_utils_yaml.py
Original file line number Diff line number Diff line change
@@ -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'
9 changes: 7 additions & 2 deletions workflows/workflow_use/healing/variable_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down