From 5c96edaeb52002d816566ab96621222231b4bf11 Mon Sep 17 00:00:00 2001 From: ewezy Date: Fri, 9 Sep 2022 14:36:03 +0800 Subject: [PATCH] Remove redundant regex route path name check --- api/turing/api/request/request.go | 8 -------- api/turing/api/request/request_test.go | 9 --------- 2 files changed, 17 deletions(-) diff --git a/api/turing/api/request/request.go b/api/turing/api/request/request.go index 53900f427..ef6a3dfad 100644 --- a/api/turing/api/request/request.go +++ b/api/turing/api/request/request.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "regexp" "github.com/caraml-dev/turing/api/turing/config" "github.com/caraml-dev/turing/api/turing/models" @@ -13,8 +12,6 @@ import ( routercfg "github.com/caraml-dev/turing/engines/router/missionctl/config" ) -var routeNamePathRegex = regexp.MustCompile(`^\w+(?:\.\w+)*$`) - // CreateOrUpdateRouterRequest structure defines the format of the request payload // when creating or updating routers type CreateOrUpdateRouterRequest struct { @@ -159,11 +156,6 @@ func (r RouterConfig) BuildRouterVersion( if len(r.Ensembler.StandardConfig.ExperimentMappings) > 0 && r.Ensembler.StandardConfig.RouteNamePath != "" { return nil, errors.New("experiment mappings and route name path cannot both be configured together") } - - // Verify that the route name path is validated by the regex expression - if !routeNamePathRegex.MatchString(r.Ensembler.StandardConfig.RouteNamePath) { - return nil, errors.New("route name path is invalid") - } } if r.Ensembler.Type == models.EnsemblerPyFuncType { if r.Ensembler.PyfuncConfig == nil { diff --git a/api/turing/api/request/request_test.go b/api/turing/api/request/request_test.go index c0ec6ac2e..809dab59e 100644 --- a/api/turing/api/request/request_test.go +++ b/api/turing/api/request/request_test.go @@ -475,15 +475,6 @@ func TestRequestBuildRouterVersionWithInvalidStandardEnsembler(t *testing.T) { }, err: "experiment mappings and route name path cannot both be configured together", }, - "failure | invalid route name path": { - testEnsembler: models.Ensembler{ - Type: models.EnsemblerStandardType, - StandardConfig: &models.EnsemblerStandardConfig{ - RouteNamePath: "abc def", - }, - }, - err: "route name path is invalid", - }, } // Run tests