PG1204 opened a new issue, #6445:
URL: https://github.com/apache/texera/issues/6445

   ### What happened?
   
   ### What happened?
   The computing-unit sharing endpoints crash with a NullPointerException 
(surfaced to the client as HTTP 500) when the target email does not belong to 
any existing user.
   
   In ComputingUnitAccessResource, both grantAccess and revokeAccess do:
   
   val granteeId = userDao.fetchOneByEmail(email).getUid
   if (granteeId == null) {
     throw new IllegalArgumentException("User with the given email does not 
exist")
   }
   userDao.fetchOneByEmail(email) returns null when no account matches the 
email, so .getUid throws an NPE before the null-check on the next line runs. 
The null-check is therefore dead code, and the intended clean error ("User with 
the given email does not exist") is never produced.
   
   Expected: granting/revoking to a nonexistent email returns a clear client 
error (e.g. 400 Bad Request / IllegalArgumentException "User with the given 
email does not exist").
   Actual: an opaque 500 Internal Server Error from an uncaught 
NullPointerException.
   
   Affected code:
   
computing-unit-managing-service/.../resource/ComputingUnitAccessResource.scala 
, grantAccess (~line 155) and revokeAccess (~line 183)
   (Note: the same pattern with a proper null-check exists correctly elsewhere, 
e.g. isOwner checks unit != null before dereferencing; only these two methods 
dereference first.)
   
   ### How to reproduce?
   
   Enable computing-unit sharing (COMPUTING_UNIT_SHARING_ENABLED=true).
   As the owner of a computing unit, call the grant endpoint with an email that 
has no account: PUT /access/computing-unit/grant/{cuid}/[email protected]/READ
   Observe an HTTP 500 response caused by a NullPointerException, instead of a 
4xx "user does not exist" error.
   Same result for the revoke endpoint: DELETE 
/access/computing-unit/revoke/{cuid}/[email protected]
   (Mistyping a teammate's email in the share dialog is the common real-world 
trigger.)
   
   ### Version/Branch
   
   1.3.0-incubating-SNAPSHOT (main)
   
   ### Commit Hash (Optional)
   
   _No response_
   
   ### What browsers are you seeing the problem on?
   
   _No response_
   
   ### Relevant log output
   
   ```shell
   java.lang.NullPointerException
        at 
org.apache.texera.service.resource.ComputingUnitAccessResource.grantAccess(ComputingUnitAccessResource.scala:155)
        ...
   => HTTP 500 Internal Server Error
   ```


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