This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git
The following commit(s) were added to refs/heads/main by this push:
new 312a0cefc5 fix(amber): return 403 instead of 401 when a user lacks
access to an execution (#9325)
312a0cefc5 is described below
commit 312a0cefc54ed3bc6b810dfdb07589df1b872e99
Author: Meng Wang <[email protected]>
AuthorDate: Thu Nov 5 05:12:50 2026 +0000
fix(amber): return 403 instead of 401 when a user lacks access to an
execution (#9325)
### What changes were proposed in this PR?
`validateUserCanAccessExecutions` now throws `ForbiddenException` (403)
instead of a 401. The frontend reads any 401 on an authenticated request
as an expired session, so a read-only user who bookmarked, renamed or
deleted an execution was logged out. With a 403 they stay logged in.
Bookmark puts its icon back on a refusal. Rename and delete have no
error handler, so they fail without a message; that is left out of this
PR to keep it small.
### Any related issues, documentation, discussions?
Closes #9324.
### How was this PR tested?
Added a read-only bookmark case to `WorkflowExecutionsResourceSpec`, and
the refusal cases now assert 403. Ran `sbt
"WorkflowExecutionService/testOnly *UserQuotaResourceSpec
*WorkflowExecutionsResourceSpec"`: 84 of 85 pass. The other one, the
per-user warehouse case of `retrieveWorkflowRuntimeStatistics`, fails
the same way locally on unmodified `main`. Putting the 401 back fails
the four cases this PR touches.
Not clicked through in a running instance.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-opus-5-5)
---
.../user/workflow/WorkflowExecutionsResource.scala | 2 +-
.../dashboard/user/quota/UserQuotaResourceSpec.scala | 3 ++-
.../user/workflow/WorkflowExecutionsResourceSpec.scala | 16 ++++++++++++++--
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git
a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResource.scala
b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResource.scala
index 26e0b987c0..2670e4f108 100644
---
a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResource.scala
+++
b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResource.scala
@@ -89,7 +89,7 @@ object WorkflowExecutionsResource {
): Unit = {
eids.distinct.foreach { eid =>
if (!userCanAccessExecution(uid, eid, requireWrite)) {
- throw new WebApplicationException(Response.Status.UNAUTHORIZED)
+ throw new ForbiddenException("No sufficient access privilege.")
}
}
}
diff --git
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/quota/UserQuotaResourceSpec.scala
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/quota/UserQuotaResourceSpec.scala
index 760500d9f3..23787febe5 100644
---
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/quota/UserQuotaResourceSpec.scala
+++
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/quota/UserQuotaResourceSpec.scala
@@ -378,9 +378,10 @@ class UserQuotaResourceSpec extends AnyFlatSpec with
BeforeAndAfterAll with Mock
otherUser.setName("otherUser")
otherUser.setEmail("otherUser-" + UUID.randomUUID().toString.substring(0,
8) + "@example.com")
- intercept[WebApplicationException] {
+ val refused = intercept[WebApplicationException] {
resource.deleteCollection(execution.getEid, new SessionUser(otherUser))
}
+ assert(refused.getResponse.getStatus == 403)
assert(workflowExecutionsDao.fetchOneByEid(execution.getEid) != null)
}
diff --git
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResourceSpec.scala
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResourceSpec.scala
index b656a48346..720d9cfc6f 100644
---
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResourceSpec.scala
+++
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResourceSpec.scala
@@ -699,7 +699,7 @@ class WorkflowExecutionsResourceSpec
requireWrite = true
)
- intercept[WebApplicationException] {
+ intercept[ForbiddenException] {
WorkflowExecutionsResource.validateUserCanAccessExecutions(
otherUserUid,
Seq(eid),
@@ -1309,7 +1309,7 @@ class WorkflowExecutionsResourceSpec
"setExecutionAreBookmarked" should "reject a user without access" in {
val exec = insertExecution()
- assertThrows[WebApplicationException](
+ assertThrows[ForbiddenException](
resource.setExecutionAreBookmarked(
ExecutionGroupBookmarkRequest(testWorkflowWid, Array(exec.getEid),
isBookmarked = false),
session(userWithoutAccess())
@@ -1317,6 +1317,18 @@ class WorkflowExecutionsResourceSpec
)
}
+ it should "refuse a read-only user with 403, since the frontend logs out on
401" in {
+ grantReadAccess()
+ val exec = insertExecution()
+ assertThrows[ForbiddenException](
+ resource.setExecutionAreBookmarked(
+ ExecutionGroupBookmarkRequest(testWorkflowWid, Array(exec.getEid),
isBookmarked = false),
+ session(testUser)
+ )
+ )
+ assert(workflowExecutionsDao.fetchOneByEid(exec.getEid).getBookmarked ==
false)
+ }
+
it should "bookmark executions that are currently un-bookmarked" in {
grantWriteAccess()
val exec = insertExecution() // bookmarked = false