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 f8c127e6dd feat(amber): reject invalid dashboard resource type (#8144)
f8c127e6dd is described below
commit f8c127e6dd51cb74d623cd34f5c8d92b7367c556
Author: carloea2 <[email protected]>
AuthorDate: Wed Nov 4 02:39:02 2026 +0000
feat(amber): reject invalid dashboard resource type (#8144)
### What changes were proposed in this PR?
Return `BadRequestException` for an unknown dashboard resource type
instead of an unhandled `IllegalArgumentException`.
Before: invalid resource types return 500.
After: they return 400 with a specific message.
Update the exception assertions in both dashboard test suites.
### Any related issues, documentation, discussions?
Closes #8143
### How was this PR tested?
Retested in a fresh detached worktree from upstream main at
`7426431337`, which includes #8938. The regression assertions failed
before the implementation change: 3 failed and 83 passed. After the
change, all 86 focused tests pass.
Used JDK 17 and a disposable PostgreSQL database initialized from
`sql/texera_ddl.sql`. The tests use embedded PostgreSQL. Object-storage
endpoints were isolated for the passing run.
```powershell
$env:STORAGE_JDBC_URL='jdbc:postgresql://127.0.0.1:55489/oct15_review?currentSchema=texera_db,public'
$env:STORAGE_S3_ENDPOINT='http://127.0.0.1:1'
$env:STORAGE_LAKEFS_ENDPOINT='http://127.0.0.1:1/api/v1'
sbt -batch "WorkflowExecutionService/testOnly *DashboardResourceSpec
*dashboard.file.WorkflowResourceSpec -- -oDF" "scalafixAll --check"
scalafmtCheckAll
```
Repository lint, formatting and whitespace checks pass.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Codex
---
.../apache/texera/web/resource/dashboard/DashboardResource.scala | 2 +-
.../texera/web/resource/dashboard/DashboardResourceSpec.scala | 6 ++++--
.../texera/web/resource/dashboard/file/WorkflowResourceSpec.scala | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git
a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/DashboardResource.scala
b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/DashboardResource.scala
index 5a70f35dd5..05c576cbd6 100644
---
a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/DashboardResource.scala
+++
b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/DashboardResource.scala
@@ -105,7 +105,7 @@ object DashboardResource {
val datasetQuery = DatasetSearchQueryBuilder.constructQuery(uid,
params, includePublic)
val modelQuery = ModelSearchQueryBuilder.constructQuery(uid, params,
includePublic)
workflowQuery.unionAll(datasetQuery).unionAll(modelQuery)
- case _ => throw new IllegalArgumentException(s"Unknown resource type:
${params.resourceType}")
+ case _ => throw new BadRequestException(s"Unknown resource type:
${params.resourceType}")
}
val finalQuery =
diff --git
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/DashboardResourceSpec.scala
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/DashboardResourceSpec.scala
index 279e04ed58..25aa5c8034 100644
---
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/DashboardResourceSpec.scala
+++
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/DashboardResourceSpec.scala
@@ -28,6 +28,8 @@ import org.jooq.{OrderField, SQLDialect}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
+import javax.ws.rs.BadRequestException
+
/**
* Covers the connection-free surface of [[DashboardResource]]: the `orderBy`
* translation and the resource-type dispatch guard.
@@ -128,7 +130,7 @@ class DashboardResourceSpec extends AnyFlatSpec with
Matchers {
// constructQuery / SqlServer, so this is reachable with no database. The
// exception *type* is the real assertion: if the guard were moved below
the
// query construction, this would surface as a SqlServer failure instead.
- val thrown = the[IllegalArgumentException] thrownBy
DashboardResource.searchAllResources(
+ val thrown = the[BadRequestException] thrownBy
DashboardResource.searchAllResources(
new SessionUser(new User()), // uid stays null; unused on this path
SearchQueryParams(resourceType = "notAResourceType")
)
@@ -138,7 +140,7 @@ class DashboardResourceSpec extends AnyFlatSpec with
Matchers {
it should "reject a resourceType that only differs from a valid one by case"
in {
// Guards against someone relaxing the match to be case-insensitive on one
// side only: "Workflow" is not "workflow" today.
- val thrown = the[IllegalArgumentException] thrownBy
DashboardResource.searchAllResources(
+ val thrown = the[BadRequestException] thrownBy
DashboardResource.searchAllResources(
new SessionUser(new User()),
SearchQueryParams(resourceType = "Workflow")
)
diff --git
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala
index e57ae21d08..501c4e3f05 100644
---
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala
+++
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala
@@ -731,7 +731,7 @@ class WorkflowResourceSpec
// dataset is dropped during hydration when LakeFS is unreachable, so it
cannot be counted
// here -- DatasetSearchQueryBuilderSpec covers that path against a stub).
Asserting that an
// unrecognised value is rejected pins that resourceType is dispatched on,
not ignored.
- assertThrows[IllegalArgumentException] {
+ assertThrows[BadRequestException] {
dashboardResource.searchAllResourcesCall(
sessionUser1,
SearchQueryParams(resourceType = "project", keywords =
getKeywordsArray("test"))