The GitHub Actions job "Running Copilot Code Review" on texera.git/main has failed. Run started by GitHub user Copilot (triggered by Copilot).
Head commit for run: 8df38afe777b1240c5c9263fb16862ccb199f441 / Prateek Ganigi <[email protected]> fix(computing-unit): fix 500s in share/revoke (unknown email + privilege change) (#6446) ### What changes were proposed in this PR? Fixes two HTTP 500s in ComputingUnitAccessResource's sharing endpoints, both hit by ordinary user actions. 1. Sharing/revoking to an unknown email -> 500 (NPE). grantAccess and revokeAccess read userDao.fetchOneByEmail(email).getUid before null-checking: val granteeId = userDao.fetchOneByEmail(email).getUid // NPE when email is unknown if (granteeId == null) { ... } // dead code, never reached fetchOneByEmail returns null for an unknown email, so .getUid threw an NPE before the guard, surfacing as an opaque 500, which is the intended "User with the given email does not exist" error was unreachable. Both methods now null-check the fetched user first, so an unknown email returns a clear IllegalArgumentException (4xx). Mistyping an email when sharing is common, so this replaces a server error with an actionable message. 2. Changing an existing collaborator's access level -> 500 (duplicate key). grantAccess used insert, so re-granting a user who already had access - what the share dialog does when you change a privilege via the dropdown, violated the (cuid, uid) primary key. Switched to merge (upsert) so re-granting updates the privilege in place, matching DatasetAccessResource/WorkflowAccessResource/ProjectAccessResource, from which this resource had diverged. ### Any related issues, documentation, discussions? Closes #6445 ### How was this PR tested? Added ComputingUnitAccessResourceSpec (embedded Postgres via MockTexeraDB), 8 tests covering both methods: happy path, unknown email (fix 1), re-grant privilege change (fix 2), and no-write-access. Verified red->green: against the old code the unknown-email cases fail with NullPointerException and the re-grant case with a duplicate-key IntegrityConstraintViolationException; after the fixes all 8 pass. The module had no DB-backed test wiring, so build.sbt adds DAO % "test->test" (for MockTexeraDB + embedded Postgres) and forks 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. Report URL: https://github.com/apache/texera/actions/runs/29532736592 With regards, GitHub Actions via GitBox
