This is an automated email from the ASF dual-hosted git repository.
roryqi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 5a3c59534d [#10175]improvement(PartitionOperations): include partition
path parameter in getPartition error handling (#10388)
5a3c59534d is described below
commit 5a3c59534d0e49fd11ce0fc56530132d8fe0a307
Author: Sambhavi Pandey <[email protected]>
AuthorDate: Fri Mar 20 13:28:10 2026 +0530
[#10175]improvement(PartitionOperations): include partition path parameter
in getPartition error handling (#10388)
### What changes were proposed in this pull request?
Passed the actual partition path parameter to the exception handler in
the PartitionOperations#getPartition
### Why are the changes needed?
PartitionOperations#getPartition catches exceptions and calls
ExceptionHandlers.handlePartitionException(OperationType.GET, "", table,
e). Passing an empty partition string drops the requested partition
identifier from the generated error message/context.
Fix: #10175
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
unit test
---
.../server/web/rest/PartitionOperations.java | 2 +-
.../server/web/rest/TestPartitionOperations.java | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git
a/server/src/main/java/org/apache/gravitino/server/web/rest/PartitionOperations.java
b/server/src/main/java/org/apache/gravitino/server/web/rest/PartitionOperations.java
index 4e7b12a935..cc46d88bf5 100644
---
a/server/src/main/java/org/apache/gravitino/server/web/rest/PartitionOperations.java
+++
b/server/src/main/java/org/apache/gravitino/server/web/rest/PartitionOperations.java
@@ -162,7 +162,7 @@ public class PartitionOperations {
return response;
});
} catch (Exception e) {
- return ExceptionHandlers.handlePartitionException(OperationType.GET, "",
table, e);
+ return ExceptionHandlers.handlePartitionException(OperationType.GET,
partition, table, e);
}
}
diff --git
a/server/src/test/java/org/apache/gravitino/server/web/rest/TestPartitionOperations.java
b/server/src/test/java/org/apache/gravitino/server/web/rest/TestPartitionOperations.java
index ea3dd7ec61..2c27c9c7db 100644
---
a/server/src/test/java/org/apache/gravitino/server/web/rest/TestPartitionOperations.java
+++
b/server/src/test/java/org/apache/gravitino/server/web/rest/TestPartitionOperations.java
@@ -249,6 +249,25 @@ public class TestPartitionOperations extends JerseyTest {
Assertions.assertTrue(errorResp2.getMessage().contains("p3"));
}
+ @Test
+ public void testGetPartitionExceptionMessageContainsPartitionName() {
+ doThrow(new NoSuchPartitionException("missing partition"))
+ .when(dispatcher)
+ .getPartition(any(), any());
+
+ Response resp =
+ target(partitionPath(metalake, catalog, schema, table) + "p3")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .accept("application/vnd.gravitino.v1+json")
+ .get();
+
+ Assertions.assertEquals(Response.Status.NOT_FOUND.getStatusCode(),
resp.getStatus());
+
+ ErrorResponse errorResponse = resp.readEntity(ErrorResponse.class);
+ Assertions.assertEquals(ErrorConstants.NOT_FOUND_CODE,
errorResponse.getCode());
+ Assertions.assertTrue(errorResponse.getMessage().contains("[p3]"));
+ }
+
@Test
public void testAddPartition() {
when(dispatcher.addPartition(any(), any())).thenReturn(partition1);