bug: The consumer can not be delete by dashboard which created by admin API
- Why do you submit this issue?
- [ ] Question or discussion
- [x] Bug
- [ ] Requirements
- [ ] Feature or performance improvement
- [ ] Other
I used admin API created a consumer like this
curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"username": "user123",
"plugins": {
"jwt-auth": {
"key": "dd",
"secret": "my-secret-key"
}
}
}'
but when I try to delete it by dashboard, it prompt error

but when I try to delete it by dashboard, it prompt error
What is the request sent by the front end at this time?
Is there a network API call?
@membphis request
Request URL: http://127.0.0.1:8080/apisix/admin/consumers/
Request Method: DELETE
Status Code: 200 OK
response

Request URL: http://127.0.0.1:8080/apisix/admin/consumers/ Request Method: DELETE
the URL should be wrong. missing consumer name.
https://github.com/apache/apisix/blob/master/doc/admin-api.md#consumer
@membphis That’s because the API doesn’t return consumer name.
Why the update time is 1970 in dashboard? @juzhiyuan

@membphis This issue is related to API, that's because the API doesn't return ID as agreed.
https://github.com/apache/apisix-dashboard/blob/v2.0/web/src/pages/Consumer/List.tsx#L65
Why the update time is 1970 in dashboard? @juzhiyuan
because the date returned from API is invalid.
@idbeta Why not paste the response here?
@membphis That’s because the API doesn’t return consumer name.
But the user name can display in dashboard
@membphis That’s because the API doesn’t return consumer name.
But the user name can display in dashboard
ID has been used since the beginning, and no one tells us to fallback to a username.

@membphis @moonming And according to this doc, we MUST use the ID as the key instead of the username.
the id and username must be the same. if they were not the same, will return an error message. confirm this.
if we can get username, we should use username. if not, we can use id.
I create an issue right now to fix the doc issue: https://github.com/apache/apisix/issues/2651
@juzhiyuan
if we can get
username, we should useusername. if not, we can useid.
frontend should use this way to read the consumer id.
Why the frontend should do this fallback? If it's sure that we must use the username as identify (from docs), then both fe and backend should use the username.
I check the process in APISIX, I am sure that we can use username is enough. then we can ignore the field id.
use the username as identify (from docs), then both fe and backend should use the username
agree +1
@juzhiyuan if we both use username, please confirm the frontend need to update.
it shows you mainly use id now:
https://github.com/apache/apisix-dashboard/issues/718#issuecomment-723427291
Yes, the frontend has to update the consumer.
@nic-chen please confim if we need any update for manager-api. I think we do not need to update manager-api.
if we do not need to update manager-api, we should remove the label backend.
@nic-chen please confim if we need any update for manager-api. I think we do not need to update
manager-api.if we do not need to update
manager-api, we should remove the labelbackend.
yes, we do not need to update manager-api.
https://github.com/apache/apisix-dashboard/blob/v2.0/api/internal/handler/consumer/consumer.go#L102-L110
Should the manager-api still handle ID? cc @nic-chen @membphis