This is an automated email from the ASF dual-hosted git repository.
xiangfu0 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 26aa88a2dea Fix SchemaUtils to include validation failure reason in
error message (#18896)
26aa88a2dea is described below
commit 26aa88a2dea67fa062c23f25c4b6fabc806ea327
Author: Akanksha kedia <[email protected]>
AuthorDate: Wed Jul 8 01:17:31 2026 +0530
Fix SchemaUtils to include validation failure reason in error message
(#18896)
The updateSchema endpoint in PinotSchemaRestletResource was catching
SchemaBackwardIncompatibleException but only returning a generic message
("Only allow adding new columns") without including the actual reason
from the exception. This made it difficult for users to understand why
their schema update was rejected.
Now the error response includes e.getMessage() which contains detailed
incompatibility information (missing columns, incompatible field types,
primary key changes, and fix suggestions).
---
.../api/resources/PinotSchemaRestletResource.java | 2 +-
.../controller/api/PinotSchemaRestletResourceTest.java | 16 +++++++++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java
index f2fcaa50937..7cf819a9cd6 100644
---
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java
+++
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java
@@ -477,7 +477,7 @@ public class PinotSchemaRestletResource {
} catch (SchemaBackwardIncompatibleException e) {
_controllerMetrics.addMeteredGlobalValue(ControllerMeter.CONTROLLER_SCHEMA_UPLOAD_ERROR,
1L);
throw new ControllerApplicationException(LOGGER,
- String.format("Backward incompatible schema %s. Only allow adding
new columns", schemaName),
+ String.format("Backward incompatible schema %s. Reason: %s",
schemaName, e.getMessage()),
Response.Status.BAD_REQUEST, e);
} catch (TableNotFoundException e) {
_controllerMetrics.addMeteredGlobalValue(ControllerMeter.CONTROLLER_SCHEMA_UPLOAD_ERROR,
1L);
diff --git
a/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotSchemaRestletResourceTest.java
b/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotSchemaRestletResourceTest.java
index 088031e93ec..2dc7f7356c6 100644
---
a/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotSchemaRestletResourceTest.java
+++
b/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotSchemaRestletResourceTest.java
@@ -107,9 +107,10 @@ public class PinotSchemaRestletResourceTest {
// Update the schema with addSchema api and override on
expectValidationException(() ->
adminClient.getSchemaClient().createSchema(schema.toSingleLineJsonString()));
- // Update the schema with updateSchema api
- expectValidationException(
- () -> adminClient.getSchemaClient().updateSchema(schemaName,
schema.toSingleLineJsonString()));
+ // Update the schema with updateSchema api - verify the error message
includes the actual reason
+ expectValidationExceptionWithMessage(
+ () -> adminClient.getSchemaClient().updateSchema(schemaName,
schema.toSingleLineJsonString()),
+ "Incompatible field specifications");
// Change the column data type from STRING to BOOLEAN
newColumnFieldSpec.setDataType(DataType.BOOLEAN);
@@ -308,6 +309,15 @@ public class PinotSchemaRestletResourceTest {
assertTrue(cause instanceof PinotAdminValidationException, "Unexpected
exception: " + cause);
}
+ private void expectValidationExceptionWithMessage(ThrowingRunnable runnable,
String expectedMessageSubstring) {
+ RuntimeException runtimeException =
+ expectThrows(RuntimeException.class, () -> runUnchecked(runnable));
+ Throwable cause = unwrap(runtimeException);
+ assertTrue(cause instanceof PinotAdminValidationException, "Unexpected
exception: " + cause);
+ assertTrue(cause.getMessage().contains(expectedMessageSubstring),
+ "Expected message to contain '" + expectedMessageSubstring + "' but
was: " + cause.getMessage());
+ }
+
private void expectNotFoundException(ThrowingRunnable runnable) {
RuntimeException runtimeException =
expectThrows(RuntimeException.class, () -> runUnchecked(runnable));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]