Skip to content

fix(computing-unit, v1.2): fix 500s in share/revoke (unknown email + privilege change) - #7008

Open
Yicong-Huang wants to merge 1 commit into
release/v1.2from
backport/6446-fix-500s-in-share-revoke-v1.2
Open

fix(computing-unit, v1.2): fix 500s in share/revoke (unknown email + privilege change) #7008
Yicong-Huang wants to merge 1 commit into
release/v1.2from
backport/6446-fix-500s-in-share-revoke-v1.2

Conversation

@Yicong-Huang

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Backport of #6446 to release/v1.2, cherry-picked from 8df38af.

Source fix only. #'s test and its test-only build dependency (configs(Test).dependsOn(DAO % "test->test")) are omitted — the test spec does not exist on release/v1.2. Only the source fix is carried over, per maintainer guidance.

Any related issues, documentation, discussions?

Backport of #6446. Originally linked #6445.

How was this PR tested?

Release-branch CI runs on this PR.

Was this PR authored or co-authored using generative AI tooling?

Yes — backport prepared with Claude Code (cherry-pick + manual conflict resolution; the change itself is #6446 by its original author).

🤖 Generated with Claude Code

…ege 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.

(backported from commit 8df38af)
@Yicong-Huang Yicong-Huang added the release/v1.2 back porting to release/v1.2 label Jul 29, 2026
@Yicong-Huang
Yicong-Huang requested a review from xuang7 July 29, 2026 04:36
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @seongjinyoon
    You can notify them by mentioning @seongjinyoon in a comment.

@github-actions github-actions Bot added the platform Non-amber Scala service paths label Jul 29, 2026
@Yicong-Huang Yicong-Huang removed the release/v1.2 back porting to release/v1.2 label Jul 29, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.95%. Comparing base (fd5f487) to head (c712d64).
⚠️ Report is 2 commits behind head on release/v1.2.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...service/resource/ComputingUnitAccessResource.scala 0.00% 8 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##             release/v1.2    #7008   +/-   ##
===============================================
  Coverage           53.95%   53.95%           
  Complexity           1441     1441           
===============================================
  Files                 809      809           
  Lines               34144    34144           
  Branches             3448     3447    -1     
===============================================
  Hits                18421    18421           
  Misses              14815    14815           
  Partials              908      908           
Flag Coverage Δ *Carryforward flag
access-control-service 64.61% <ø> (ø)
agent-service 34.36% <ø> (ø) Carriedforward from fd5f487
amber 59.61% <ø> (ø) Carriedforward from fd5f487
computing-unit-managing-service 1.65% <0.00%> (ø)
config-service 56.06% <ø> (ø)
file-service 58.59% <ø> (ø)
frontend 47.19% <ø> (ø) Carriedforward from fd5f487
pyamber 90.87% <ø> (ø) Carriedforward from fd5f487
python 90.74% <ø> (ø) Carriedforward from fd5f487
workflow-compiling-service 58.69% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform Non-amber Scala service paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants