apisix-dashboard icon indicating copy to clipboard operation
apisix-dashboard copied to clipboard

bug: route's description input more than 200 Chinese characters, no error message, but the route is useless

Open idbeta opened this issue 6 years ago • 15 comments

  • 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. image

In fact: image

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"}

idbeta avatar Nov 11 '20 07:11 idbeta

Here is my guess:

image

In Lua, the length of one Chinese character is 3, because we use UT8 encode by default. The length is 1 in Golang land.

membphis avatar Nov 12 '20 16:11 membphis

we should use the same way for this field

membphis avatar Nov 12 '20 16:11 membphis

😂😂 does this mean the frontend has to calculate the length? Too wired to do this.

juzhiyuan avatar Nov 13 '20 01:11 juzhiyuan

Lua\Golang\JS should use the same way to calculate the length.

Any good idea about this?

membphis avatar Nov 15 '20 03:11 membphis

Here is my guess:

image

In Lua, the length of one Chinese character is 3, because we use UT8 encode by default. The length is 1 in Golang land.

  1. It needs to be determined whether we want 200 characters or Chinese characters.
  2. The frontend shows we need no more than 200 characters, then it should be no more than 200 / 3 = 66 Chinese. Is it enough for users? or that's what we want in the beginning?
  3. 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?

juzhiyuan avatar Nov 15 '20 03:11 juzhiyuan

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 than 200 / 3 = 66 Chinese. Is it enough for users?

I think this is fine. 66 characters should be enough for dashboard user. +1 with my vote

membphis avatar Nov 17 '20 15:11 membphis

This issue still should be under discussion, I'm sure there has something we don't consider currently.

juzhiyuan avatar Nov 17 '20 16:11 juzhiyuan

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

liuxiran avatar Jan 18 '21 06:01 liuxiran

I would prefer limiting the string length, this is easy to understand for users :)

juzhiyuan avatar Jan 18 '21 06:01 juzhiyuan

@nic-chen Please leave your comments :)

juzhiyuan avatar Jan 21 '21 06:01 juzhiyuan

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.

spacewander avatar Jan 21 '21 06:01 spacewander

@idbeta Can this issue be reproduced in the latest version of dashboard? Is there any error log in the APISIX size?

spacewander avatar Jan 21 '21 07:01 spacewander

@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

idbeta avatar Jan 21 '21 07:01 idbeta

So now only the dashboard has the problem? @juzhiyuan Could you help us to confirm it?

spacewander avatar Jan 21 '21 08:01 spacewander

confirmed, the FE just modified the placeholder.

juzhiyuan avatar Jan 21 '21 09:01 juzhiyuan