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

[refactor][bug] bind params to struct error should response error with 400 status #568

Closed
nic-chen opened this issue Oct 20, 2020 · 7 comments · Fixed by #899
Closed

[refactor][bug] bind params to struct error should response error with 400 status #568

nic-chen opened this issue Oct 20, 2020 · 7 comments · Fixed by #899
Assignees
Labels
bug Something isn't working
Milestone

Comments

@nic-chen
Copy link
Member

now it response normal.

here is an example:

$ curl http://127.0.0.1:8080/apisix/admin/services/1  -X PUT -i -d '
{
    "upstream": {
        "nodes": {
            "127.0.0.1:8080": 1
        },
        "type": "roundrobin"
    },
    "labels": {
        "env": ["production", "release"]
    },
    "desc": "new service"
}'

@nic-chen
Copy link
Member Author

@ShiningRush please take a look~

@juzhiyuan juzhiyuan added the bug Something isn't working label Oct 20, 2020
@juzhiyuan juzhiyuan added this to the 1.6 milestone Oct 20, 2020
@juzhiyuan
Copy link
Member

ping @ShiningRush

@ShiningRush
Copy link
Contributor

I'm still considering the solution, if there are any results, I will sync here

@juzhiyuan
Copy link
Member

if this is not urgent, feel free to move it to milestone 2.1.

@juzhiyuan juzhiyuan modified the milestones: 2.0, 2.1 Oct 22, 2020
idbeta added a commit to idbeta/apisix-dashboard that referenced this issue Nov 23, 2020
@idbeta
Copy link
Contributor

idbeta commented Nov 26, 2020

error format ofenv

{
    caseDesc: "create consumers with invalid format of label value",
    Object:   MangerApiExpect(t),
    Path:     "/apisix/admin/consumers",
    Method:   http.MethodPost,
    Body: `{
        "username":"case_10",
        "desc": "new consumer",
        "labels": {
            "env": ["production", "release"]
        }
    }`,
    Headers:      map[string]string{"Authorization": token},
    ExpectStatus: http.StatusBadRequest,
},

miss , in json

{
			Object:   MangerApiExpect(t),
			Method:   http.MethodPut,
			Path:     "/apisix/admin/routes/r1",
			Body: `{
					"uris": ["/hello","/status"]
					"upstream": {
						"type": "roundrobin",
						"nodes": [{
							"host": "172.16.238.20",
							"port": 1980,
							"weight": 1
						}]
					}
				}`,
			Headers:      map[string]string{"Authorization": token},
			ExpectStatus: http. StatusBadRequest,
			Sleep:        sleepTime,
		}

bad methods

{
			 caseDesc: "add route with invalid uri",
			 Object:   MangerApiExpect(t),
			 Method:   http.MethodPut,
			 Path:     "/apisix/admin/routes/r1",
			 Body: `{
					 "uri": "/hello",
					 "methods": [99999999999999999],
					 "upstream": {
						 "type": "roundrobin",
						 "nodes": [{
							 "host": "172.16.238.20",
							 "port": 1980,
							 "weight": 1
						 }]
					 }
				 }`,
			 Headers:      map[string]string{"Authorization": token},
			 ExpectStatus: http. StatusBadRequest,
		 },

bad priority

{
			 caseDesc: "add route with invalid data type priority",
			 Object:   MangerApiExpect(t),
			 Method:   http.MethodPut,
			 Path:     "/apisix/admin/routes/r1",
			 Body: `{
					  "uri": "/hello",
					  "priority": "dfssdfs",
					  "upstream": {
						  "type": "roundrobin",
						  "nodes": [{
							  "host": "172.16.238.20",
							  "port": 1980,
							  "weight": 1
						  }]
					  }
				  }`,
			 Headers:      map[string]string{"Authorization": token},
			 ExpectStatus: http.StatusBadRequest,
		 },

it return 200 now.

@membphis
Copy link
Member

I think JSON Schema can check this case

@nic-chen
Copy link
Member Author

I think JSON Schema can check this case

It has returned before the json schema verification

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

Successfully merging a pull request may close this issue.

5 participants