apache / gravitino

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
https://gravitino.apache.org
Apache License 2.0
1.1k stars 345 forks source link

[Bug report] When the role name contains #, deleteRole method doesn't work #3232

Closed lw-yang closed 3 months ago

lw-yang commented 6 months ago

Version

main branch

Describe what's wrong

use gravitinoAdminClient.deleteRole("metalake",'role#test"); to delete role role#test, it doesn't work, even though the role actually exists

When there's a # sign in the URL, the content after # is considered as the URI's fragment identifier and won't be sent to the server.

The reuest url is api/metalakes/metalake/roles/role#test, the "#test" will be ignored, in other scenarios involving path parameters, there are similar issues.

We should use the URLEncoder to encode special characters in the URL, ensure they are correctly sent to the server.

Error message and/or stacktrace

java.lang.RuntimeException: Failed to operate object [role] operation [DELETE] under [metalake], reason [No such role entity: role] com.datastrato.gravitino.exceptions.NoSuchEntityException: No such role entity: role at com.datastrato.gravitino.storage.relational.service.RoleMetaService.getRoleIdByMetalakeIdAndName(RoleMetaService.java:55) at com.datastrato.gravitino.storage.relational.service.RoleMetaService.deleteRole(RoleMetaService.java:112) at com.datastrato.gravitino.storage.relational.JDBCBackend.delete(JDBCBackend.java:193) at com.datastrato.gravitino.storage.relational.RelationalEntityStore.delete(RelationalEntityStore.java:109) at com.datastrato.gravitino.EntityStore.delete(EntityStore.java:147) at com.datastrato.gravitino.authorization.RoleManager.deleteRole(RoleManager.java:127) at com.datastrato.gravitino.authorization.AccessControlManager.lambda$deleteRole$15(AccessControlManager.java:296) at com.datastrato.gravitino.authorization.AccessControlManager.doWithNonAdminLock(AccessControlManager.java:328) at com.datastrato.gravitino.authorization.AccessControlManager.deleteRole(AccessControlManager.java:296)

How to reproduce

create role with the role name contains #, then delete role

Additional context

No response

jerqi commented 3 months ago

Do you need role name like test#test? Maybe we should avoid the similar name.