Skip to content

templateDefaults validations are too strict #1505

@gmeshkov

Description

@gmeshkov

Pre-bug-report checklist

1. This bug can be reproduced using pure Argo YAML

If yes, it is more likely to be an Argo bug unrelated to Hera. Please double check before submitting an issue to Hera.

2. I have searched for existing issues

  • Yes

3. This bug occurs in Hera when...

  • exporting to YAML
  • submitting to Argo
  • running on Argo with the Hera runner
  • other: parsing workflow from JSON downloaded from an Argo cluster

Bug report

Describe the bug
A clear and concise description of what the bug is:
In Hera, template_defaults field is typed as an optional[Template]

template_defaults: Annotated[
Optional[Template],

However, as per Argo Workflows documentation, it is just a collection of overrides, not a full template. So if you download a workflow from a cluster where it was complimented with templateDefaults, pydantic in Hera fails the validations, expecting a full Template where e.g. something like this can be present:

    templateDefaults:
      inputs: {}
      outputs: {}
      metadata: {}
      container:
        name: ''
        env:
          - name: ARGO_INSTALLATION
            value: us-east2
        resources: {}
      script:
        name: ''
        env:
          - name: ARGO_INSTALLATION
            value: us-east2
        resources: {}
        source: ''

Error log if applicable:

   File ".../my_project/argo/util/api.py", line 120, in _get_graph_json_rest
    return Workflow.parse_obj(result.json())
   File ".../pydantic/x86_64_linux/lib/python3.12/site-packages/pydantic/v1/main.py", line 526, in parse_obj
    return cls(**obj)
           ^^^^^^^^^^
  File ".../pydantic/x86_64_linux/lib/python3.12/site-packages/pydantic/v1/main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 2 validation errors for Workflow
status -> storedWorkflowTemplateSpec -> templateDefaults -> container -> image
  field required (type=value_error.missing)
status -> storedWorkflowTemplateSpec -> templateDefaults -> script -> image
  field required (type=value_error.missing)```

**To Reproduce**
Full Hera code to reproduce the bug:
```py
# Not applicable, as requires templateDefaults being set up on the cluster

Expected behavior
Workflow is parsed all right.

Environment

  • Hera Version: 5.14.3
  • Python Version: 3.12
  • Argo Version: 3.5.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions