apisix-dashboard
apisix-dashboard copied to clipboard
health check has an error message
Issue description
1、add new route; 2、enable health check and add a header parameter; 3、modify route and remove the header parameter; 4、when i submit , there is an error message displayed in the browser
Expected behavior
add route success
How to Reproduce
1、add new route; 2、enable health check; 3、add a header parameter ; 4、submit; 5、modify this route; 6、remove the header parameter; 7、submit;
Screenshots
Environment
- apisix version (cmd:
apisix version
):2.11.0 - OS (cmd:
uname -a
):linux - OpenResty / Nginx version (cmd:
nginx -V
oropenresty -V
):openresty/1.19.9.1 - etcd version, if have (cmd: run
etcd --version
):etcd Version: 3.4.13 - apisix-dashboard version, if have:2.11.0
- Browser version, if have: chrome(97.0.4692.71)
Additional context
I checked the apisix code. req_headers is an array, if req_headers not nil ,then there is at least one value in req_headers. So I think apisix-dashboard pass apisix an empty array,like this: req_headers[]。 Then apisix validate failed,error message is: Array must have at least 1 items
Hi @840963657, thanks for your report. After examination, there is indeed this problem. Would you like to help fix this problem?
The reason
The request headers in the health check are empty by default, and in this case, there is no req_headers
field in the request data sent by the web to the API. However, when the user makes changes in this field, especially by removing all request headers, the data sent to the API contains the req_headers
field and the value is an empty array, which causes an error.
Possible solutions
The UI form ensures that requests sent to the API always do not contain the req_headers
field, regardless of whether the initial value of the request header is empty or the user removes all the request headers. And send the correct array of data to the API after the user has entered the request headers
Hi @840963657, thanks for your report. After examination, there is indeed this problem. Would you like to help fix this problem?
The reason
The request headers in the health check are empty by default, and in this case, there is no
req_headers
field in the request data sent by the web to the API. However, when the user makes changes in this field, especially by removing all request headers, the data sent to the API contains thereq_headers
field and the value is an empty array, which causes an error.Possible solutions
The UI form ensures that requests sent to the API always do not contain the
req_headers
field, regardless of whether the initial value of the request header is empty or the user removes all the request headers. And send the correct array of data to the API after the user has entered the request headers
I‘m sorry,I'm not familiar with JS...’
The UI form ensures that requests sent to the API always do not contain the
req_headers
field, regardless of whether the initial value of the request header is empty or the user removes all the request headers. And send the correct array of data to the API after the user has entered the request headers
@Si-ege Do you have time to help solve this problem?
I can try to complete the question