-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(schema-validator) does not convert the null
in the declarative configuration to nil
#8483
Conversation
ngx.null
for limits.{limit_name}.*
Co-authored-by: Datong Sun <datong.sun@konghq.com>
Co-authored-by: Datong Sun <datong.sun@konghq.com>
|
||
if not usage[k] then | ||
usage[k] = {} | ||
if lv ~= null then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand why the lv
can be null
, but can it be nil
too, thus?
if lv ~= null then | |
if lv ~= nil and lv ~= null then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #8483 (comment) .
@bungle plugins:
- name: response-ratelimiting
config:
limits:
test:
second: null
hour: 1000
block_on_first_violation: false
policy: cluster
fault_tolerant: true
hide_client_headers: false
However, this case does not occur if we use the Admin API to configure this plugin, this configuration will be recognized as invalid. curl -i -X POST http://{admin_host}/consumers/{consumer_id}/plugins \
--data "name=response-ratelimiting" \
--data "config.limits.test.hour=1000" \
--data "config.limits.test.minute=null" \
--data "config.block_on_first_violation=false" \
--data "config.policy=cluster" \
--data "config.fault_tolerant=true" \
--data "config.hide_client_headers=false" \
--data "config.header_name=X-Kong-Limit" The response is: {
"fields": {
"config": {
"limits": {
"minute": "expected a number"
}
}
},
"code": 2,
"name": "schema violation",
"message": "schema violation (config.limits: {\n minute = \"expected a number\"\n})"
} The same goes for curl -i -X PATCH http://{admin_host}/consumers/{consumer_Id}/plugins/{plugin_id} \
--data "config.limits.test.minute=null" The response is: {
"message": "schema violation (config.limits: {\n minute = \"expected a number\"\n})",
"name": "schema violation",
"fields": {
"config": {
"limits": {
"minute": "expected a number"
}
}
},
"code": 2
} For I think this might be a bug. For |
Co-authored-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
ngx.null
for limits.{limit_name}.*
null
in the declarative configuration to nil
Summary
If
config.limits.{limit_name}.*
isnull
, this plugin will raise a HTTP 500 error.Full changelog
config.limits.{limit_name}.*
isnull
, skip it.spec/03-plugins/24-response-rate-limiting/01-schema_spec.lua
.Issue reference
Fix #8314