Copilot commented on code in PR #9130:
URL: https://github.com/apache/ozone/pull/9130#discussion_r2417133340


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMDirectoriesPurgeRequestWithFSO.java:
##########
@@ -111,8 +111,11 @@ public OMClientResponse 
validateAndUpdateCache(OzoneManager ozoneManager, Execut
         // Validating previous snapshot can ensure the chain hasn't changed.
         UUID expectedPreviousSnapshotId = 
purgeDirsRequest.getExpectedPreviousSnapshotID().hasUuid()
             ? 
fromProtobuf(purgeDirsRequest.getExpectedPreviousSnapshotID().getUuid()) : null;
-        validatePreviousSnapshotId(fromSnapshotInfo, 
omMetadataManager.getSnapshotChainManager(),
-            expectedPreviousSnapshotId);
+        if (!validatePreviousSnapshotId(fromSnapshotInfo, 
omMetadataManager.getSnapshotChainManager(),
+            expectedPreviousSnapshotId)) {
+          return new 
OMDirectoriesPurgeResponseWithFSO(createErrorOMResponse(omResponse,
+              new OMException("Snapshot validation failed", 
OMException.ResultCodes.INVALID_REQUEST)));
+        }

Review Comment:
   The error message 'Snapshot validation failed' is too generic and doesn't 
provide enough context for debugging. Consider adding more specific information 
about what aspect of validation failed or why the request should be retried.
   ```suggestion
             String actualPrevSnapshotId = (fromSnapshotInfo != null && 
fromSnapshotInfo.getPreviousSnapshot() != null)
                 ? fromSnapshotInfo.getPreviousSnapshot().toString() : "null";
             String errorMsg = String.format(
                 "Snapshot validation failed for fromSnapshot='%s': expected 
previousSnapshotId=%s, actual previousSnapshotId=%s",
                 fromSnapshot, 
                 expectedPreviousSnapshotId != null ? 
expectedPreviousSnapshotId.toString() : "null",
                 actualPrevSnapshotId
             );
             return new 
OMDirectoriesPurgeResponseWithFSO(createErrorOMResponse(omResponse,
                 new OMException(errorMsg, 
OMException.ResultCodes.INVALID_REQUEST)));
   ```



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