diff --git a/common/namespace/attrValidator.go b/common/namespace/attrValidator.go index 0f612f0a751..2aadb7efbad 100644 --- a/common/namespace/attrValidator.go +++ b/common/namespace/attrValidator.go @@ -32,7 +32,9 @@ import ( "go.temporal.io/api/serviceerror" persistencespb "go.temporal.io/server/api/persistence/v1" + "go.temporal.io/server/common" "go.temporal.io/server/common/cluster" + "go.temporal.io/server/common/primitives/timestamp" ) type ( @@ -56,7 +58,9 @@ func newAttrValidator( } func (d *AttrValidatorImpl) validateNamespaceConfig(config *persistencespb.NamespaceConfig) error { - if config.Retention != nil && *config.Retention < time.Hour*24*time.Duration(d.minRetentionDays) { + if timestamp.DurationValue(config.Retention) < time.Hour*24*time.Duration(d.minRetentionDays) { + return errInvalidRetentionPeriod + } else if timestamp.DurationValue(config.Retention) > common.MaxWorkflowRetentionPeriod { return errInvalidRetentionPeriod } if config.HistoryArchivalState == enumspb.ARCHIVAL_STATE_ENABLED && len(config.HistoryArchivalUri) == 0 { diff --git a/service/frontend/errors.go b/service/frontend/errors.go index d2e2946b133..5bb39b8ae52 100644 --- a/service/frontend/errors.go +++ b/service/frontend/errors.go @@ -43,7 +43,6 @@ var ( errRequestNotSet = serviceerror.NewInvalidArgument("Request is nil.") errRequestIDNotSet = serviceerror.NewInvalidArgument("RequestId is not set on request.") errWorkflowTypeNotSet = serviceerror.NewInvalidArgument("WorkflowType is not set on request.") - errInvalidRetention = serviceerror.NewInvalidArgument("RetentionDays is invalid.") errInvalidWorkflowExecutionTimeoutSeconds = serviceerror.NewInvalidArgument("An invalid WorkflowExecutionTimeoutSeconds is set on request.") errInvalidWorkflowRunTimeoutSeconds = serviceerror.NewInvalidArgument("An invalid WorkflowRunTimeoutSeconds is set on request.") errInvalidWorkflowTaskTimeoutSeconds = serviceerror.NewInvalidArgument("An invalid WorkflowTaskTimeoutSeconds is set on request.") diff --git a/service/frontend/workflowHandler.go b/service/frontend/workflowHandler.go index 046e690af2e..3d28f043e19 100644 --- a/service/frontend/workflowHandler.go +++ b/service/frontend/workflowHandler.go @@ -222,10 +222,6 @@ func (wh *WorkflowHandler) RegisterNamespace(ctx context.Context, request *workf return nil, errRequestNotSet } - if timestamp.DurationValue(request.GetWorkflowExecutionRetentionPeriod()) > common.MaxWorkflowRetentionPeriod { - return nil, errInvalidRetention - } - if request.GetNamespace() == "" { return nil, errNamespaceNotSet }