Ma77Ball commented on code in PR #6446:
URL: https://github.com/apache/texera/pull/6446#discussion_r3593153869


##########
computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitAccessResource.scala:
##########
@@ -152,18 +152,22 @@ class ComputingUnitAccessResource {
     }
 
     // TODO: add try except and check how to display error message in the 
frontend
-    val granteeId = userDao.fetchOneByEmail(email).getUid
-    if (granteeId == null) {
+    val grantee = userDao.fetchOneByEmail(email)
+    if (grantee == null) {
       throw new IllegalArgumentException("User with the given email does not 
exist")
     }
+    val granteeId = grantee.getUid

Review Comment:
   Optional, non-blocking: this fetch + null-check + getUid block is now 
identical in grantAccess and revokeAccess (same message). Consider lifting it 
to a small private helper so the two stay in sync. This is a manual two-spot 
change (add the helper, then replace both blocks with `val granteeId = 
resolveUidByEmail(email)`), so no click-to-commit suggestion:
   
   ```scala
   private def resolveUidByEmail(email: String): Integer = {
     val user = userDao.fetchOneByEmail(email)
     if (user == null) {
       throw new IllegalArgumentException("User with the given email does not 
exist")
     }
     user.getUid
   }
   ```



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