fix(healing): read YAML workflow files in process_workflow_file_with_markers - #177
RaphaelFakhri wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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>
| 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) |
There was a problem hiding this comment.
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>
| json.dump(updated_workflow.model_dump(), f, indent=2) | |
| json.dump(updated_workflow.model_dump(mode='json'), f, indent=2) |
Summary
process_workflow_file_with_markerscalledjson.loadon every input file, so it raisedJSONDecodeErroron the.workflow.yamlfiles thatWorkflowStorageServicewrites. The function now reads the file withyaml.safe_load, which also reads JSON, and writes the output as YAML when the output path ends in.yamlor.ymland as JSON otherwise.Fixes #156
Tests
cd workflows && uv run pytest workflow_use/healing/tests/test_variable_utils.pyruff checkandruff format --checkpass onworkflow_use/healing.Summary by cubic
Fixed
process_workflow_file_with_markersto read and write YAML workflow files, matching the formatWorkflowStorageServiceproduces.json.loadwithyaml.safe_loadso JSON and YAML inputs both load correctly..yamlor.yml, and JSON otherwise.Written for commit ed36ca8. Summary will update on new commits.