Skip to content

Commit

Permalink
\Revert "fix collection not exist" (accidental push to main) (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
tatu-at-datastax authored Nov 1, 2023
1 parent e0d6279 commit c2250b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -42,23 +41,14 @@ protected Uni<CollectionSettings> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit c2250b4

Please sign in to comment.