bug: route's description input more than 200 Chinese characters, no error message, but the route is useless
- Why do you submit this issue?
- [ ] Question or discussion
- [x] Bug
- [ ] Requirements
- [ ] Feature or performance improvement
- [ ] Other
Route's description can input more than 200 Chinese characters, no error, but the route is useless.

In fact:

the route's useless, but the etcd will store the route data
$ curl http://127.0.0.1:9080/404.html
{"error_msg":"404 Route Not Found"}
Here is my guess:

In Lua, the length of one Chinese character is 3, because we use UT8 encode by default. The length is 1 in Golang land.
we should use the same way for this field
😂😂 does this mean the frontend has to calculate the length? Too wired to do this.
Lua\Golang\JS should use the same way to calculate the length.
Any good idea about this?
Here is my guess:
In Lua, the length of one Chinese character is
3, because we use UT8 encode by default. The length is 1 in Golang land.
- It needs to be determined whether we want 200 characters or Chinese characters.
- The frontend shows we need no more than
200 characters, then it should be no more than200 / 3 = 66Chinese. Is it enough for users? or that's what we want in the beginning? - It's not easy to fix this issue, need more cases discussion, I don't have a conclusion currently.
BTW, may I know why Lua will limit 200 characters? for performance or anything else?
BTW, may I know why Lua will limit 200 characters? for performance or anything else?
We didn't know that different languages have this problem before. 200 characters is enough for most cases.
2. The frontend shows we need no more than
200 characters, then it should be no more than200 / 3 = 66Chinese. Is it enough for users?
I think this is fine. 66 characters should be enough for dashboard user. +1 with my vote
This issue still should be under discussion, I'm sure there has something we don't consider currently.
Just take Js for an example(sorry for not familiar with Golang and Lua):
there is a string 'please take a look 一一':
- the length of this string is 21, IMHO, this is what we are expected result;
- the utf-8 byte length is 25. In fact a Chinese character is 3 byte long in JS too, may be these is equal to the current Lua result.
If we need to limit the length of use input characters, we'd better limit the string length instead of string byte length, the reason is that the string length is the same as the length user visually see, and at the same time we don't need to distinguish between languages.
If we can reach a consensus, the only question is that: is there a method which can get the string length in Lua?
waiting for your reply, thanks a lot
cc @membphis @nic-chen @starsz @tokers @imjoey
I would prefer limiting the string length, this is easy to understand for users :)
@nic-chen Please leave your comments :)
Hey guys. Something you don't make it correct from the beginning:
https://github.com/api7/jsonschema/blob/b9375642eb2da0f20486a38025e511a12687b5d4/lib/jsonschema.lua#L365
The Lua implementation doesn't use # to get the length of data. Instead, it counts the string length instead of the string bytes.
If we need to limit the length of use input characters, we'd better limit the string length instead of string byte length
Yes. We have already done this.
Maybe there is something else causes the problem.
@idbeta Can this issue be reproduced in the latest version of dashboard? Is there any error log in the APISIX size?
@idbeta Can this issue be reproduced in the latest version of dashboard? Is there any error log in the APISIX size?
1、can not more than 200 characters
still can
2、the route is useless
no problem now
So now only the dashboard has the problem? @juzhiyuan Could you help us to confirm it?
confirmed, the FE just modified the placeholder.