Skip to content

[Cherry-pick to branch-1.3] [#12879] fix(server): return accurate HTTP statuses for unsupported operations (#12880) - #12924

Merged
jerryshao merged 2 commits into
branch-1.3from
cherry-pick-8e41cedf-to-branch-1.3
Sep 4, 2026
Merged

[Cherry-pick to branch-1.3] [#12879] fix(server): return accurate HTTP statuses for unsupported operations (#12880)#12924
jerryshao merged 2 commits into
branch-1.3from
cherry-pick-8e41cedf-to-branch-1.3

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Cherry-pick Information:

  • Original commit: 8e41ced
  • Target branch: branch-1.3
  • Status: ⚠️ Has conflicts - manual resolution required

Do not merge until conflict markers are resolved and the
cherry-pick-conflict label is removed.

Please review and resolve the conflicts before merging.

…perations (#12880)

### What changes were proposed in this pull request?

- Classify REST failures by semantics at the common exception-handling
boundary:
- Return HTTP 400 when statistics endpoints receive a non-table object
type.
- Return HTTP 409 when an operation conflicts with object state,
including unmodifiable statistics and non-empty IdP groups.
- Return HTTP 501 for recognized but unsupported server or connector
capabilities, including handlers that use the common fallback.
- Preserve the authorization-disabled filter's existing HTTP 405
contract through a dedicated helper instead of sharing the
unsupported-capability helper.
- Align the built-in IdP mapper so unsupported operations return 501 and
unexpected `IllegalStateException` returns 500.
- Keep the existing application error codes so Java clients continue
reconstructing the same exceptions.
- Update OpenAPI contracts and make Web v2 recognize unsupported
operations by application error code, with HTTP 501 as a fallback, so it
works with both old and new servers.

### Why are the changes needed?

HTTP 405 means the request method is not supported by the target
resource. The reported failures use valid registered methods and instead
represent invalid input, resource conflicts, or unavailable
functionality. The old mapping was also inconsistent because resource
handlers without a dedicated branch returned HTTP 500 for the same
unsupported-capability exception.

The fix centralizes the fallback while classifying more specific domain
exceptions before the generic `UnsupportedOperationException` branch.

Fix: #12879

### Does this PR introduce _any_ user-facing change?

Yes. Invalid statistics object types return HTTP 400, state conflicts
return HTTP 409, and unsupported REST capabilities return HTTP 501.
Response payload codes remain compatible. The authorization-disabled
filter keeps its existing HTTP 405 behavior.

### How was this patch tested?

- `./gradlew spotlessApply`
- `./gradlew :server-common:test --tests
org.apache.gravitino.server.web.TestUtils -PskipITs
-PskipDockerTests=true`
- `./gradlew :server:test --tests
org.apache.gravitino.server.web.filter.TestAccessControlNotAllowedFilter
--tests org.apache.gravitino.server.web.rest.TestExceptionHandlers
--tests org.apache.gravitino.server.web.rest.TestStatisticOperations
-PskipITs -PskipDockerTests=true`
- `./gradlew :clients:client-java:test --tests
org.apache.gravitino.client.TestSupportsStatistics --tests
org.apache.gravitino.client.TestSupportsPartitionStatistics -PskipITs
-PskipDockerTests=true`
- `./gradlew :plugins:idp-basic:test --tests
org.apache.gravitino.idp.web.TestIdpRESTUtils --tests
org.apache.gravitino.idp.TestIdpUserGroupManager -PskipITs
-PskipDockerTests=true`
- `./gradlew :plugins:idp-basic:test --tests
org.apache.gravitino.idp.integration.test.IdpRESTApiIT
-PskipDockerTests=true`
- `./gradlew :docs:build -PskipITs -PskipDockerTests=true`
- `pnpm exec vitest run
src/lib/utils/axios/unsupportedOperation.test.js`
- `pnpm prettier:check`
- `pnpm lint`
# Conflicts:
#	server-common/src/test/java/org/apache/gravitino/server/web/TestUtils.java
#	server/src/main/java/org/apache/gravitino/server/web/rest/ExceptionHandlers.java
#	server/src/test/java/org/apache/gravitino/server/web/rest/TestExceptionHandlers.java
@github-actions github-actions Bot added cherry-pick Automatically opened cherry-pick PR cherry-pick-conflict Cherry-pick has conflicts; needs human resolution before merge labels Sep 4, 2026
@github-actions
github-actions Bot requested a review from jerryshao September 4, 2026 09:16
Keep only what 8e41ced introduced. The conflicting hunks also carried
main-only context that branch-1.3 never had: the ConnectionFailedException
and OptimisticLockException branches in BaseExceptionHandler, their imports,
and testOptimisticLockConflictReturnsConflict. Those come from other commits
and are dropped here rather than back-ported as a side effect of this one.

Add the ErrorConstants import to TestUtils, which main already had and
branch-1.3 did not, so the new assertions compile.

Claude-Session: https://claude.ai/code/session_01EPJduJLZAREBg1bKxybe1e
@yuqi1129 yuqi1129 changed the title [DO NOT MERGE] [Cherry-pick to branch-1.3] [#12879] fix(server): return accurate HTTP statuses for unsupported operations (#12880) [Cherry-pick to branch-1.3] [#12879] fix(server): return accurate HTTP statuses for unsupported operations (#12880) Sep 4, 2026
@jerryshao jerryshao removed the cherry-pick-conflict Cherry-pick has conflicts; needs human resolution before merge label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Author

Code Coverage Report

Overall Project 68.97% +0.14% 🟢
Files changed 71.35% 🟢

Module Coverage
aliyun 19.74% 🔴
api 47.62% 🟢
authorization-common 85.96% 🟢
aws 53.54% 🟢
azure 32.1% 🔴
catalog-common 10.4% -0.02% 🔴
catalog-fileset 80.51% 🟢
catalog-glue 69.24% 🟢
catalog-hive 79.42% 🟢
catalog-jdbc-clickhouse 84.7% 🟢
catalog-jdbc-common 45.47% 🟢
catalog-jdbc-doris 82.61% 🟢
catalog-jdbc-hologres 54.03% 🟢
catalog-jdbc-mysql 79.33% 🟢
catalog-jdbc-oceanbase 78.6% 🟢
catalog-jdbc-postgresql 83.39% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 77.27% 🟢
catalog-lakehouse-generic 59.35% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.86% -1.68% 🟢
catalog-lakehouse-paimon 82.17% 🟢
catalog-model 77.99% 🟢
cli 44.51% 🟢
client-java 78.31% 🟢
common 50.74% 🟢
core 82.97% -1.79% 🟢
filesystem-hadoop3 77.3% 🟢
flink 0.0% 🔴
flink-common 49.22% 🟢
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-common 15.43% 🔴
hive-metastore-common 53.77% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 58.18% -6.41% 🟢
iceberg-rest-server 73.97% -1.19% 🟢
idp-basic 86.76% +1.42% 🟢
integration-test-common 0.0% 🔴
jobs 66.17% 🟢
lance-common 24.42% 🔴
lance-rest-server 60.13% 🟢
lineage 53.02% +1.64% 🟢
optimizer 82.95% 🟢
optimizer-api 21.95% 🔴
server 88.8% +0.66% 🟢
server-common 76.35% +0.82% 🟢
spark 28.57% 🔴
spark-common 45.69% 🟢
trino-connector 57.36% 🟢
Files
Module File Coverage
catalog-common IcebergConstants.java 0.0% 🔴
catalog-lakehouse-iceberg IcebergCatalogOperations.java 79.86% 🟢
core SchemaHookDispatcher.java 92.0% 🟢
FilesetHookDispatcher.java 85.29% 🟢
TableOperationDispatcher.java 84.22% 🟢
ViewOperationDispatcher.java 82.73% 🟢
TopicHookDispatcher.java 82.61% 🟢
FunctionHookDispatcher.java 71.43% 🟢
CatalogManager.java 69.36% 🟢
AuthorizationUtils.java 63.86% 🟢
JobHookDispatcher.java 59.26% 🔴
MetadataObjectUtil.java 58.02% 🔴
ModelHookDispatcher.java 56.82% 🔴
TagHookDispatcher.java 47.62% 🔴
PolicyHookDispatcher.java 41.67% 🔴
MetalakeHookDispatcher.java 40.62% 🔴
AccessControlHookDispatcher.java 38.27% 🔴
CatalogHookDispatcher.java 33.33% 🔴
GravitinoEnv.java 12.5% 🔴
iceberg-common IcebergCatalogUtil.java 66.3% 🟢
IcebergCatalogWrapper.java 29.15% 🔴
iceberg-rest-server IcebergCatalogWrapperManager.java 70.49% 🟢
DynamicIcebergConfigProvider.java 38.84% 🔴
idp-basic IdpRESTUtils.java 97.62% 🟢
IdpGroupMetaService.java 95.4% 🟢
lineage LineageOperations.java 78.57% 🟢
server AccessControlNotAllowedFilter.java 100.0% 🟢
GroupOperations.java 100.0% 🟢
UserOperations.java 100.0% 🟢
StatisticOperations.java 94.83% 🟢
GravitinoInterceptionService.java 93.69% 🟢
ExceptionHandlers.java 87.03% 🟢
AuthorizeExecutorFactory.java 25.0% 🔴
AuthorizationExecutor.java 0.0% 🔴
server-common JcasbinAuthorizer.java 88.34% 🟢
MetadataAuthzHelper.java 60.69% 🟢
Utils.java 51.79% 🔴
AuthorizationRequest.java 0.0% 🔴

@jerryshao
jerryshao merged commit f2e5906 into branch-1.3 Sep 4, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick Automatically opened cherry-pick PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants