1. This bug can be reproduced using pure Argo YAML
2. I have searched for existing issues
3. This bug occurs in Hera when...
Bug report
Describe the bug
Hera's to_yaml() method uses PyYAML's default 80-character line width, which breaks long template expressions across multiple lines, making them syntactically invalid for Argo Workflows.
To Reproduce
from hera.workflows import WorkflowTemplate
from hera.workflows import models as m
# Create a workflow with a long template expression
wt = WorkflowTemplate(
name="test-yaml-wrapping",
workflow_metadata=m.WorkflowMetadata(
annotations={
"workflows.argoproj.io/description": "ref={{= sprig.trunc(7, workflow.parameters.gh-ref) }}, push={{ workflow.parameters.push }}"
}
)
)
print("Current output (breaks template expression):")
print(wt.to_yaml())
print("\nWith width=160 (keeps template expression intact):")
print(wt.to_yaml(width=160))
Expected behavior
Template expressions should remain on a single line to maintain their syntactic validity:
workflowMetadata:
annotations:
workflows.argoproj.io/description: ref={{= sprig.trunc(7, workflow.parameters.gh-ref) }}, push={{ workflow.parameters.push }}
Actual behavior
Template expressions are broken across lines, making them invalid:
workflowMetadata:
annotations:
workflows.argoproj.io/description: ref={{= sprig.trunc(7, workflow.parameters.gh-ref)
}}, push={{ workflow.parameters.push }}
Additional context
We could set a reasonable default width (like 160) to fix the issue? Would you like me to create a PR @elliotgunton?
def dump(*args, **kwargs) -> str:
# Set some default options if not provided by the user
kwargs.setdefault("default_flow_style", False)
kwargs.setdefault("sort_keys", False)
kwargs.setdefault("width", 160) # 👈🏼 👈🏼 👈🏼
return _yaml.dump(*args, **kwargs)
1. This bug can be reproduced using pure Argo YAML
2. I have searched for existing issues
3. This bug occurs in Hera when...
Bug report
Describe the bug
Hera's
to_yaml()method uses PyYAML's default 80-character line width, which breaks long template expressions across multiple lines, making them syntactically invalid for Argo Workflows.To Reproduce
Expected behavior
Template expressions should remain on a single line to maintain their syntactic validity:
Actual behavior
Template expressions are broken across lines, making them invalid:
Additional context
We could set a reasonable default width (like 160) to fix the issue? Would you like me to create a PR @elliotgunton?