diff --git a/flyteadmin/pkg/manager/impl/validation/execution_validator.go b/flyteadmin/pkg/manager/impl/validation/execution_validator.go index b01e878b5b..3143c41f88 100644 --- a/flyteadmin/pkg/manager/impl/validation/execution_validator.go +++ b/flyteadmin/pkg/manager/impl/validation/execution_validator.go @@ -68,6 +68,9 @@ func ValidateExecutionRequest(ctx context.Context, request admin.ExecutionCreate return err } } + if err := validateLabels(request.Spec.Labels); err != nil { + return err + } return nil } diff --git a/flyteadmin/pkg/manager/impl/validation/execution_validator_test.go b/flyteadmin/pkg/manager/impl/validation/execution_validator_test.go index 3029ce6dc4..0040ee2759 100644 --- a/flyteadmin/pkg/manager/impl/validation/execution_validator_test.go +++ b/flyteadmin/pkg/manager/impl/validation/execution_validator_test.go @@ -66,6 +66,25 @@ func TestValidateExecInvalidProjectAndDomain(t *testing.T) { assert.EqualError(t, err, "failed to validate that project [project] and domain [domain] are registered, err: [foo]") } +func TestValidateExecInvalidLabels(t *testing.T) { + request := testutils.GetExecutionRequest() + request.Spec.Labels = &admin.Labels{ + Values: map[string]string{ + "foo": "#bar", + }, + } + err := ValidateExecutionRequest(context.Background(), request, testutils.GetRepoWithDefaultProject(), execConfig) + assert.ErrorContains(t, err, "invalid label value [#bar]:") + + request.Spec.Labels = &admin.Labels{ + Values: map[string]string{ + "#foo": "bar", + }, + } + err = ValidateExecutionRequest(context.Background(), request, testutils.GetRepoWithDefaultProject(), execConfig) + assert.ErrorContains(t, err, "invalid label key [#foo]:") +} + func TestGetExecutionInputs(t *testing.T) { executionRequest := testutils.GetExecutionRequest() lpRequest := testutils.GetLaunchPlanRequest()