bitflicker64 commented on code in PR #880:
URL: 
https://github.com/apache/hugegraph-toolchain/pull/880#discussion_r4432076856


##########
hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/service/graph/GraphService.java:
##########
@@ -263,12 +266,26 @@ public GraphView importJson(HugeClient client, 
MultipartFile jsonFile) throws IO
                 EdgeHolder edgeHolder = this.buildEdge(client, entity,
                                                        createdVertices);
                 Edge edge = graph.addEdge(edgeHolder.edge);
-                addedEdgeIds.add(edge.id());
+                acknowledgedEdges++;
                 edges.put(edge.id(), edge);
             }
         } catch (RuntimeException e) {
-            this.rollbackImport(graph, addedVertexIds, addedEdgeIds);
-            throw e;
+            // Server writes can replace existing elements, and a failed 
request
+            // can have committed before its response was lost. Deleting IDs
+            // returned by earlier writes is therefore not a safe rollback.
+            log.warn("Graph JSON import failed; changes may remain (failure 
type: {})",
+                     e.getClass().getName());
+            int status = 400;
+            if (e instanceof ExternalException) {
+                status = ((ExternalException) e).status();
+            } else if (e instanceof ServerException) {
+                int upstream = ((ServerException) e).status();
+                if (upstream == 401 || upstream == 403) {
+                    status = upstream;
+                }
+            }
+            throw new ExternalException(status, 
"graph.import.partial-failure", e,

Review Comment:
   Important: `ExceptionAdvisor` never renders `cause` and the warn log keeps 
only the class name, so a write the Server rejects now hides its reason, where 
the base showed the sanitized `ServerException` message. Pass the cause message 
as an argument to `graph.import.partial-failure` in both locales so the user 
sees why the import failed.



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

Reply via email to