Skip to content

Commit

Permalink
fix: validation for timeouts in upstream schema that can be zero (#3401)
Browse files Browse the repository at this point in the history
  • Loading branch information
yitian-reevo authored Jan 25, 2021
1 parent 1819b6b commit e02baeb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apisix/schema_def.lua
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ local upstream_schema = {
timeout = {
type = "object",
properties = {
connect = {type = "number", minimum = 0},
send = {type = "number", minimum = 0},
read = {type = "number", minimum = 0},
connect = {type = "number", exclusiveMinimum = 0},
send = {type = "number", exclusiveMinimum = 0},
read = {type = "number", exclusiveMinimum = 0},
},
required = {"connect", "send", "read"},
},
Expand Down
33 changes: 33 additions & 0 deletions t/admin/upstream2.t
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,36 @@ GET /index.html
--- error_code: 502
--- error_log
no valid upstream node
=== TEST 9: upstream timeouts equal to zero
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/upstreams/1',
ngx.HTTP_PUT,
[[{
"nodes": {
"127.0.0.1:8080": 1
},
"type": "roundrobin",
"timeout": {
"connect": 0,
"send": 0,
"read": 0
}
}]]
)
ngx.status = code
ngx.print(body)
}
}
--- request
GET /t
--- error_code: 400
--- response_body_like eval
qr/{"error_msg":"invalid configuration: property \\\"timeout\\\" validation failed: property \\\"(connect|send|read)\\\" validation failed: expected 0 to be sctrictly greater than 0"}/
--- no_error_log
[error]

0 comments on commit e02baeb

Please sign in to comment.