PG1204 opened a new pull request, #6446:
URL: https://github.com/apache/texera/pull/6446
### What changes were proposed in this PR?
ComputingUnitAccessResource.grantAccess and revokeAccess looked up the
target user with userDao.fetchOneByEmail(email).getUid and only then
null-checked the result:
val granteeId = userDao.fetchOneByEmail(email).getUid // NPE when email is
unknown
if (granteeId == null) { ... } // dead code which
never got reached
fetchOneByEmail returns null when no account matches the email, so .getUid
threw a NullPointerException before the guard ran, surfacing to the client as
an opaque HTTP 500. The intended "User with the given email does not exist"
error was unreachable.
This PR reorders both methods to fetch the user object, null-check it, and
only then read .getUid, so an unknown email now yields a clear
IllegalArgumentException (4xx) instead of a 500. Sharing to a
mistyped/nonexistent email is a common user action, so this turns a confusing
server error into an actionable message.
### Any related issues, documentation, discussions?
Closes #6445
### How was this PR tested?
Added ComputingUnitAccessResourceSpec (embedded Postgres via MockTexeraDB)
covering both methods: the happy path, the unknown-email case (the regression
this PR fixes), and the no-write-access case. Verified red-then-green — against
the old ordering both unknown-email tests fail with NullPointerException; after
the fix all 7 pass.
This module had no DB-backed test wiring, so build.sbt was updated to add
DAO % "test->test" (for MockTexeraDB + embedded Postgres) and to fork the test
JVM with COMPUTING_UNIT_SHARING_ENABLED=true and the repo root as the working
directory (so MockTexeraDB can resolve sql/texera_ddl.sql).
Run:
sbt "ComputingUnitManagingService/testOnly
org.apache.texera.service.resource.ComputingUnitAccessResourceSpec"
### Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.8 in compliance with ASF
--
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]