Skip to content

Commit 3577391

Browse files
Start converting vectorize codes
1 parent f71f58f commit 3577391

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCodeV1.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ public enum ErrorCodeV1 {
2121

2222
VECTOR_SEARCH_INVALID_FUNCTION_NAME("Invalid vector search function name"),
2323

24-
VECTOR_SEARCH_UNRECOGNIZED_SOURCE_MODEL_NAME("Unrecognized vector search source model name"),
25-
2624
VECTOR_SEARCH_TOO_BIG_VALUE("Vector embedding property '$vector' length too big"),
2725

2826
VECTORIZE_FEATURE_NOT_AVAILABLE("Vectorize feature is not available in the environment"),

src/main/java/io/stargate/sgv2/jsonapi/exception/SchemaException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public enum Code implements ErrorCode<SchemaException> {
9191
UNSUPPORTED_VECTOR_DIMENSION,
9292
UNSUPPORTED_VECTOR_INDEX_FOR_DATA_TYPES,
9393

94+
VECTOR_SEARCH_UNRECOGNIZED_SOURCE_MODEL_NAME, // legacy: converted from ErrorCodeV1
95+
9496
// older below - separated because they need to be confirmed
9597
INVALID_KEYSPACE,
9698
INVALID_VECTORIZE_FIELD_CONFIGURATION,

src/main/java/io/stargate/sgv2/jsonapi/service/schema/EmbeddingSourceModel.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.stargate.sgv2.jsonapi.service.schema;
22

3-
import io.stargate.sgv2.jsonapi.exception.ErrorCodeV1;
4-
import io.stargate.sgv2.jsonapi.exception.JsonApiException;
3+
import io.stargate.sgv2.jsonapi.exception.APIException;
4+
import io.stargate.sgv2.jsonapi.exception.SchemaException;
55
import java.util.Arrays;
66
import java.util.List;
77
import java.util.Map;
@@ -192,8 +192,10 @@ public static Optional<EmbeddingSourceModel> fromApiNameOrDefault(String apiName
192192
* the caller should decide when to throw. Moved to be a public method here so it can be used by
193193
* the caller.
194194
*/
195-
public static JsonApiException getUnknownSourceModelException(String apiName) {
196-
return ErrorCodeV1.VECTOR_SEARCH_UNRECOGNIZED_SOURCE_MODEL_NAME.toApiException(
197-
"Received: '%s'; Accepted: %s", apiName, String.join(", ", allApiNames()));
195+
public static APIException getUnknownSourceModelException(String apiName) {
196+
return SchemaException.Code.VECTOR_SEARCH_UNRECOGNIZED_SOURCE_MODEL_NAME.get(
197+
Map.of(
198+
"errorMessage",
199+
"Received: '%s'; Accepted: %s".formatted(apiName, String.join(", ", allApiNames()))));
198200
}
199201
}

src/main/resources/errors.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,12 @@ request-errors:
17901790
17911791
Resend the command using a known metric.
17921792
1793+
- scope: SCHEMA
1794+
code: VECTOR_SEARCH_UNRECOGNIZED_SOURCE_MODEL_NAME
1795+
title: Unrecognized vector search source model name
1796+
body: |-
1797+
Unrecognized vector search source model name: ${errorMessage}.
1798+
17931799
- scope: SCHEMA
17941800
code: CANNOT_DROP_UNKNOWN_INDEX
17951801
title: Dropped index is not defined in the keyspace schema

0 commit comments

Comments
 (0)