Skip to content

fix(healing): read YAML workflow files in process_workflow_file_with_markers - #177

Open
RaphaelFakhri wants to merge 1 commit into
browser-use:mainfrom
RaphaelFakhri:fix/variable-utils-yaml-workflow
Open

RaphaelFakhri wants to merge 1 commit into
browser-use:mainfrom
RaphaelFakhri:fix/variable-utils-yaml-workflow

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Sep 29, 2026 •

Copy link
Copy Markdown

Summary

process_workflow_file_with_markers called json.load on every input file, so it raised JSONDecodeError on the .workflow.yaml files that WorkflowStorageService writes. The function now reads the file with yaml.safe_load, which also reads JSON, and writes the output as YAML when the output path ends in .yaml or .yml and as JSON otherwise.

Fixes #156

Tests

cd workflows && uv run pytest workflow_use/healing/tests/test_variable_utils.py

  • Before the fix (tests added, source reverted): 2 failed, 1 passed.
  • After the fix: 3 passed.
  • ruff check and ruff format --check pass on workflow_use/healing.

Summary by cubic

Fixed process_workflow_file_with_markers to read and write YAML workflow files, matching the format WorkflowStorageService produces.

Written for commit ed36ca8. Summary will update on new commits.

Review in cubic

Copilot AI balanced review requested due to automatic review settings September 29, 2026 13:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="workflows/workflow_use/healing/variable_utils.py">

<violation number="1" location="workflows/workflow_use/healing/variable_utils.py:64">
P2: This loader changes valid YAML string scalars such as `yes` and `on` into booleans before schema validation, so hand-authored workflows can fail on required string fields. Use a YAML 1.2-compatible scalar resolver or normalize these fields before constructing `WorkflowDefinitionSchema`.</violation>

<violation number="2" location="workflows/workflow_use/healing/variable_utils.py:77">
P2: YAML-to-JSON conversion still fails for valid YAML-native values such as unquoted dates in `verification_checks` or extra step fields. Use `model_dump(mode='json')` in the JSON branch so these values are converted before `json.dump`.</violation>
</file>

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Fix all with cubic | Re-trigger cubic

# Load the workflow. YAML is a superset of JSON, so this reads both formats.
with open(input_path, 'r') as f:
workflow_data = json.load(f)
workflow_data = yaml.safe_load(f)

@cubic-dev-ai cubic-dev-ai Bot Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This loader changes valid YAML string scalars such as yes and on into booleans before schema validation, so hand-authored workflows can fail on required string fields. Use a YAML 1.2-compatible scalar resolver or normalize these fields before constructing WorkflowDefinitionSchema.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At workflows/workflow_use/healing/variable_utils.py, line 64:

<comment>This loader changes valid YAML string scalars such as `yes` and `on` into booleans before schema validation, so hand-authored workflows can fail on required string fields. Use a YAML 1.2-compatible scalar resolver or normalize these fields before constructing `WorkflowDefinitionSchema`.</comment>

<file context>
@@ -57,19 +59,22 @@ def process_workflow_file_with_markers(
+	# Load the workflow. YAML is a superset of JSON, so this reads both formats.
 	with open(input_path, 'r') as f:
-		workflow_data = json.load(f)
+		workflow_data = yaml.safe_load(f)
 
 	workflow = WorkflowDefinitionSchema(**workflow_data)
</file context>
Fix with cubic

if output_path.suffix.lower() in ('.yaml', '.yml'):
yaml.dump(updated_workflow.model_dump(mode='json'), f, default_flow_style=False, sort_keys=False)
else:
json.dump(updated_workflow.model_dump(), f, indent=2)

@cubic-dev-ai cubic-dev-ai Bot Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: YAML-to-JSON conversion still fails for valid YAML-native values such as unquoted dates in verification_checks or extra step fields. Use model_dump(mode='json') in the JSON branch so these values are converted before json.dump.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At workflows/workflow_use/healing/variable_utils.py, line 77:

<comment>YAML-to-JSON conversion still fails for valid YAML-native values such as unquoted dates in `verification_checks` or extra step fields. Use `model_dump(mode='json')` in the JSON branch so these values are converted before `json.dump`.</comment>

<file context>
@@ -57,19 +59,22 @@ def process_workflow_file_with_markers(
+		if output_path.suffix.lower() in ('.yaml', '.yml'):
+			yaml.dump(updated_workflow.model_dump(mode='json'), f, default_flow_style=False, sort_keys=False)
+		else:
+			json.dump(updated_workflow.model_dump(), f, indent=2)
 
 	print(f'Processed workflow: {input_path}')
</file context>
Suggested change
json.dump(updated_workflow.model_dump(), f, indent=2)
json.dump(updated_workflow.model_dump(mode='json'), f, indent=2)
Fix with cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: process_workflow_file_with_markers crashes with JSONDecodeError on YAML workflow files

2 participants