Skip to content

Commit

Permalink
Remove redundant regex route path name check
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlycoconuts committed Sep 9, 2022
1 parent 772a589 commit cb4b7ef
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
8 changes: 0 additions & 8 deletions api/turing/api/request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 0 additions & 9 deletions api/turing/api/request/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cb4b7ef

Please sign in to comment.