imbajin commented on code in PR #3008:
URL: https://github.com/apache/hugegraph/pull/3008#discussion_r3187076884
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/auth/StandardAuthManagerV2.java:
##########
@@ -1510,6 +1516,195 @@ public HugeGroup findGroup(String name) {
return result;
}
+ @Override
+ public void setDefaultGraph(String graphSpace, String graph, String user) {
+ try {
+ HugeBelong belong = new HugeBelong(graphSpace,
+ IdGenerator.of(user),
+ IdGenerator.of(graph +
+
DEFAULT_SETTER_ROLE_KEY));
+ this.tryInitDefaultGraph(graphSpace, graph);
+ this.updateCreator(belong);
+ belong.create(belong.update());
+ this.metaManager.createBelong(graphSpace, belong);
Review Comment:
‼️ **Bug: setting the same default graph twice fails in PD mode**
`MetaManager.createBelong()` rejects an existing belong record, so repeated
`POST /graphs/{name}/default` calls for the same user/graph will be wrapped as
`HugeException` instead of behaving idempotently. `unsetDefaultGraph()` already
checks `existBelong()` first; `setDefaultGraph()` should do the same before
creating the belong binding.
```suggestion
String role = graph + DEFAULT_SETTER_ROLE_KEY;
String belongId = this.metaManager.belongId(user, role);
if (!this.metaManager.existBelong(graphSpace,
IdGenerator.of(belongId))) {
this.metaManager.createBelong(graphSpace, belong);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]