Skip to content

Commit

Permalink
fix: Permit enums w/o values. Fixes #11471. (#11736)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Farmer <[email protected]>
  • Loading branch information
farmdawgnation authored Oct 11, 2023
1 parent cd11a8b commit f01dbb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions workflow/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,9 @@ func validateArgumentsValues(prefix string, arguments wfv1.Arguments, allowEmpty
return errors.Errorf(errors.CodeBadRequest, "%s%s.enum should contain at least one value", prefix, param.Name)
}
if param.Value == nil {
if allowEmptyValues {
return nil
}
return errors.Errorf(errors.CodeBadRequest, "%s%s.value is required", prefix, param.Name)
}
valueSpecifiedInEnumList := false
Expand Down
4 changes: 2 additions & 2 deletions workflow/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2710,9 +2710,9 @@ func TestWorkflowTemplateWithArgumentValueNotFromEnumList(t *testing.T) {

func TestWorkflowTemplateWithEnumValueWithoutValue(t *testing.T) {
err := validateWorkflowTemplate(workflowTeamplateWithEnumValuesWithoutValue, ValidateOpts{})
assert.EqualError(t, err, "spec.arguments.message.value is required")
assert.Nil(t, err)
err = validateWorkflowTemplate(workflowTeamplateWithEnumValuesWithoutValue, ValidateOpts{Lint: true})
assert.EqualError(t, err, "spec.arguments.message.value is required")
assert.Nil(t, err)
err = validateWorkflowTemplate(workflowTeamplateWithEnumValuesWithoutValue, ValidateOpts{Submit: true})
assert.EqualError(t, err, "spec.arguments.message.value is required")
}
Expand Down

0 comments on commit f01dbb1

Please sign in to comment.