Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route name max length has different values in schema.json and /api/internal/core/entity/entity.go file #2610

Closed
alptugay opened this issue Aug 31, 2022 · 0 comments · Fixed by #2759
Assignees
Labels
backend bug Something isn't working P1

Comments

@alptugay
Copy link

Issue description

I am trying to add a route with a name of 58 characters. I am getting the following error:
{"code":10004,"message":"input validate failed: Key: 'UpdateInput.Route.Name' Error:Field validation for 'Name' failed on the 'max' tag","data":null,"request_id":"e4ff8fea-7a46-492b-9d0d-b0b81c12ad75"}
In schema.json file route name is defined with the following values (line number 409):

  "name": {
     "maxLength": 100,
     "minLength": 1,
      "type": "string"
 },

However in entity.go file the Route struct is defined as the following:

type Route struct {
        BaseInfo
        URI             string                 `json:"uri,omitempty"`
        Uris            []string               `json:"uris,omitempty"`
`        Name            string                 `json:"name" validate:"max=50"``
        Desc            string                 `json:"desc,omitempty" validate:"max=256"`
        Priority        int                    `json:"priority,omitempty"`
        Methods         []string               `json:"methods,omitempty"`
        Host            string                 `json:"host,omitempty"`
        Hosts           []string               `json:"hosts,omitempty"`
        RemoteAddr      string                 `json:"remote_addr,omitempty"`
        RemoteAddrs     []string               `json:"remote_addrs,omitempty"`
        Vars            []interface{}          `json:"vars,omitempty"`
        FilterFunc      string                 `json:"filter_func,omitempty"`
        Script          interface{}            `json:"script,omitempty"`
        ScriptID        interface{}            `json:"script_id,omitempty"` // For debug and optimization(cache), currently same as Route's ID
        Plugins         map[string]interface{} `json:"plugins,omitempty"`
        PluginConfigID  interface{}            `json:"plugin_config_id,omitempty"`
        Upstream        *UpstreamDef           `json:"upstream,omitempty"`
        ServiceID       interface{}            `json:"service_id,omitempty"`
        UpstreamID      interface{}            `json:"upstream_id,omitempty"`
        ServiceProtocol string                 `json:"service_protocol,omitempty"`
        Labels          map[string]string      `json:"labels,omitempty"`
        EnableWebsocket bool                   `json:"enable_websocket,omitempty"`
        Status          Status                 `json:"status"`
}

There seems to be an inconsistence between the two.

Expected behavior

According to the schema.json file I am expecting to be able to add a route with a name of 100 characters. Even if that would seem too much, at least I think 64 characters should be supported in the naming convention.

How to Reproduce

Add a route with a name of more than 50 characters.

Screenshots

No response

Environment

  • apisix-dashboard version 2.13.0

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug Something isn't working P1
Projects
None yet
3 participants