Copilot commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2911593735


##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
         }
     }
 
+    public static void checkPdModeEnabled(GraphManager manager) {
+        if (!manager.isUsePD()) {
+            throw new HugeException(

Review Comment:
   `HugeException` is a general internal exception and will typically be mapped 
to an HTTP 500 response, not 400 as intended and as tested. The tests assert 
HTTP 400 (`assertResponseStatus(400, r)`), but using `HugeException` directly 
will likely result in a 500. You should throw the appropriate exception type 
that maps to HTTP 400 (e.g., `IllegalArgumentException` or a 
`BadRequestException`), or use an existing API-level exception that carries the 
desired status code.
   ```suggestion
               throw new IllegalArgumentException(
   ```



##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -280,6 +280,10 @@ private boolean usePD() {
         return this.PDExist;
     }
 
+    public boolean isUsePD() {
+        return this.PDExist;
+    }

Review Comment:
   The private `usePD()` method and the newly added public `isUsePD()` method 
have identical implementations. The private method should be removed or 
replaced by delegating to the public one to avoid duplicated logic.



-- 
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]

Reply via email to