diff --git a/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java b/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java index fb0d0247b0..597ca3d546 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java @@ -10,8 +10,6 @@ public enum ErrorCode { CONCURRENCY_FAILURE("Unable to complete transaction due to concurrent transactions"), - COLLECTION_NOT_EXIST("Collection does not exist, collection name: "), - DATASET_TOO_BIG("Response data set too big to be sorted, add more filters"), DOCUMENT_ALREADY_EXISTS("Document already exists with the given _id"), diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/bridge/executor/NamespaceCache.java b/src/main/java/io/stargate/sgv2/jsonapi/service/bridge/executor/NamespaceCache.java index 2314d5551c..c64e7dc155 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/bridge/executor/NamespaceCache.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/bridge/executor/NamespaceCache.java @@ -6,7 +6,6 @@ import io.grpc.StatusRuntimeException; import io.smallrye.mutiny.Uni; import io.stargate.sgv2.jsonapi.exception.ErrorCode; -import io.stargate.sgv2.jsonapi.exception.JsonApiException; import java.time.Duration; /** Caches the vector enabled status for the namespace */ @@ -42,23 +41,14 @@ protected Uni getCollectionProperties(String collectionName) .transformToUni( (result, error) -> { if (null != error) { - // collection does not exist - if (error instanceof RuntimeException rte - && rte.getMessage() - .startsWith(ErrorCode.INVALID_COLLECTION_NAME.getMessage())) { - return Uni.createFrom() - .failure( - new JsonApiException( - ErrorCode.COLLECTION_NOT_EXIST, - ErrorCode.COLLECTION_NOT_EXIST - .getMessage() - .concat(collectionName))); - } // ignoring the error and return false. This will be handled while trying to // execute the query if ((error instanceof StatusRuntimeException sre - && (sre.getStatus().getCode() == io.grpc.Status.Code.NOT_FOUND - || sre.getStatus().getCode() == io.grpc.Status.Code.INVALID_ARGUMENT))) { + && (sre.getStatus().getCode() == io.grpc.Status.Code.NOT_FOUND + || sre.getStatus().getCode() == io.grpc.Status.Code.INVALID_ARGUMENT)) + || (error instanceof RuntimeException rte + && rte.getMessage() + .startsWith(ErrorCode.INVALID_COLLECTION_NAME.getMessage()))) { return Uni.createFrom() .item(new CollectionSettings(collectionName, false, 0, null, null, null)); } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/HttpStatusCodeIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/HttpStatusCodeIntegrationTest.java index 4cb04de19e..60bd1772e0 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/HttpStatusCodeIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/HttpStatusCodeIntegrationTest.java @@ -89,7 +89,7 @@ public void regularError() { endsWith( "INVALID_ARGUMENT: table %s.%s does not exist" .formatted(namespaceName, "badCollection")), - endsWith("INVALID_ARGUMENT: table %s does not exist".formatted("badCollection")),endsWith("Collection does not exist, collection name: %s".formatted("badCollection"))); + endsWith("INVALID_ARGUMENT: table %s does not exist".formatted("badCollection"))); given() .header(HttpConstants.AUTHENTICATION_TOKEN_HEADER_NAME, getAuthToken()) .contentType(ContentType.JSON) @@ -101,7 +101,7 @@ public void regularError() { .body("errors", is(notNullValue())) .body("errors[0].message", is(not(blankString()))) .body("errors[0].message", anyOf) - .body("errors[0].exceptionClass", is("JsonApiException")); + .body("errors[0].exceptionClass", is("StatusRuntimeException")); } @Test