Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions common/src/main/java/com/skyflow/errors/ErrorMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,25 @@ public enum ErrorMessage {
InsufficientTokensPassedForTokenModeEnableStrict("%s0 Validation error. 'tokenMode' is set to 'ENABLE_STRICT', but some fields are missing tokens. Specify tokens for all fields."),
BatchInsertPartialSuccess("%s0 Insert operation completed with partial success."),
BatchInsertFailure("%s0 Insert operation failed."),
RecordSizeExceedError("%s0 Maximum number of records exceeded. The limit is 10000."),
RecordSizeExceedError("%s0 Maximum number of records exceeded. The limit is 100000."),

// Detokenize
InvalidDetokenizeData("%s0 Validation error. Invalid detokenize data. Specify valid detokenize data."),
EmptyDetokenizeData("%s0 Validation error. Invalid data tokens. Specify at least one data token."),
EmptyTokenInDetokenizeData("%s0 Validation error. Invalid data tokens. Specify a valid data token."),
TokensSizeExceedError("%s0 Maximum number of tokens exceeded. The limit is 10000."),
TokensSizeExceedError("%s0 Maximum number of tokens exceeded. The limit is 100000."),

// Delete
DeleteRequestNull("%s0 Validation error. DeleteRequest object is null. Specify a valid DeleteRequest object."),

// Delete Tokens
DeleteTokensRequestNull("%s0 Validation error. DeleteTokensRequest object is null. Specify a valid DeleteTokensRequest object."),
EmptyDeleteTokensData("%s0 Validation error. Tokens list is empty. Specify at least one token to delete."),
EmptyTokenInDeleteTokensData("%s0 Validation error. Invalid token in delete tokens request. Specify a valid token."),
DeleteTokensSizeExceedError("%s0 Maximum number of tokens exceeded. The limit is 10000."),
DeleteTokensSizeExceedError("%s0 Maximum number of tokens exceeded. The limit is 100000."),

// Get
GetRequestNull("%s0 Validation error. GetRequest object is null. Specify a valid GetRequest object."),
IdsKeyError("%s0 Validation error. 'ids' key is missing from the payload. Specify an 'ids' key."),
EmptyIds("%s0 Validation error. 'ids' can't be empty. Specify at least one id."),
EmptyIdInIds("%s0 Validation error. Invalid id in 'ids'. Specify a valid id."),
Expand Down Expand Up @@ -141,8 +145,13 @@ public enum ErrorMessage {
SkyflowIdKeyError("%s0 Validation error. 'skyflow_id' is missing from the data payload. Specify a 'skyflow_id'."),
InvalidSkyflowIdType("%s0 Validation error. Invalid type for 'skyflow_id' in data payload. Specify 'skyflow_id' as a string."),
EmptySkyflowId("%s0 Validation error. 'skyflow_id' can't be empty. Specify a skyflow id."),
UpdateRequestNull("%s0 Validation error. UpdateRequest object is null. Specify a valid UpdateRequest object."),
UpdateRecordNull("%s0 Validation error. UpdateRequestRecord object in the list is null. Specify a valid UpdateRequestRecord object."),
RecordSkyflowIdKeyError("%s0 Validation error. 'skyflowId' key is missing from the record. Specify a 'skyflowId' key."),
EmptySkyflowIdInRecord("%s0 Validation error. 'skyflowId' can't be empty in the record. Specify a valid skyflow ID."),

// Query
QueryRequestNull("%s0 Validation error. QueryRequest object is null. Specify a valid QueryRequest object."),
QueryKeyError("%s0 Validation error. 'query' key is missing from the payload. Specify a 'query' key."),
EmptyQuery("%s0 Validation error. 'query' can't be empty. Specify a query"),

Expand All @@ -156,7 +165,7 @@ public enum ErrorMessage {
EmptyValueInTokenizeRecord("%s0 Validation error. Value in TokenizeRecord is null or empty. Specify a valid value."),
EmptyTokenGroupNamesInTokenizeRecord("%s0 Validation error. TokenGroupNames in TokenizeRecord is null or empty. Specify at least one token group name."),
EmptyTokenGroupNameInTokenizeRecord("%s0 Validation error. Token group name in TokenizeRecord is null or empty. Specify a valid token group name."),
TokenizeDataSizeExceedError("%s0 Maximum number of tokenize records exceeded. The limit is 10000."),
TokenizeDataSizeExceedError("%s0 Maximum number of tokenize records exceeded. The limit is 100000."),
MissingIndexInBulkTokenizeRecord("%s0 Validation error. Index in BulkTokenizeRequestRecord is null. Specify an index for every record."),
DuplicateIndexInBulkTokenizeRecord("%s0 Validation error. Duplicate index in BulkTokenizeRequestRecord. Specify a unique index for every record."),

Expand Down
8 changes: 4 additions & 4 deletions common/src/main/java/com/skyflow/logs/ErrorLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public enum ErrorLogs {
RECORDS_IS_REQUIRED("Invalid %s1 request. Records are required."),
EMPTY_RECORDS("Invalid %s1 request. Records can not be empty."),
INVALID_RECORD("Invalid %s1 request. Invalid record. Specify a valid record."),
RECORD_SIZE_EXCEED("Maximum number of records exceeded. The limit is 10000."),
TOKENS_SIZE_EXCEED("Maximum number of tokens exceeded. The limit is 10000."),
RECORD_SIZE_EXCEED("Maximum number of records exceeded. The limit is 100000."),
TOKENS_SIZE_EXCEED("Maximum number of tokens exceeded. The limit is 100000."),
EMPTY_OR_NULL_VALUE_IN_VALUES("Invalid %s1 request. Value can not be null or empty in values for key \"%s2\"."),
EMPTY_OR_NULL_KEY_IN_VALUES("Invalid %s1 request. Key can not be null or empty in values"),
NULL_VALUE_ENTRY_IN_VALUES("Invalid %s1 request. Value entry in 'values' can not be null at index %s2."),
Expand Down Expand Up @@ -144,15 +144,15 @@ public enum ErrorLogs {
EMPTY_VALUE_IN_TOKENIZE_RECORD("Invalid %s1 request. Value in TokenizeRecord can not be null or empty."),
EMPTY_TOKEN_GROUP_NAMES_IN_TOKENIZE_RECORD("Invalid %s1 request. TokenGroupNames in TokenizeRecord can not be null or empty."),
EMPTY_TOKEN_GROUP_NAME_IN_TOKENIZE_RECORD("Invalid %s1 request. Token group name in TokenizeRecord can not be null or empty at index %s2."),
TOKENIZE_DATA_SIZE_EXCEED("Maximum number of tokenize records exceeded. The limit is 10000."),
TOKENIZE_DATA_SIZE_EXCEED("Maximum number of tokenize records exceeded. The limit is 100000."),
MISSING_INDEX_IN_BULK_TOKENIZE_RECORD("Invalid %s1 request. Index in BulkTokenizeRequestRecord can not be null at position %s2."),
DUPLICATE_INDEX_IN_BULK_TOKENIZE_RECORD("Invalid %s1 request. Duplicate index %s2 in BulkTokenizeRequestRecord."),
DELETE_REQUEST_NULL("Invalid %s1 request. Delete request can not be null."),
DELETE_REQUEST_REJECTED("Delete request resulted in failure."),
DELETE_TOKENS_REQUEST_NULL("Invalid %s1 request. DeleteTokens request can not be null."),
EMPTY_DELETE_TOKENS_DATA("Invalid %s1 request. Delete tokens data can not be empty."),
EMPTY_OR_NULL_TOKEN_IN_DELETE_TOKENS_DATA("Invalid %s1 request. Token can not be null or empty in delete tokens data at index %s2."),
DELETE_TOKENS_SIZE_EXCEED("Maximum number of tokens exceeded. The limit is 10000."),
DELETE_TOKENS_SIZE_EXCEED("Maximum number of tokens exceeded. The limit is 100000."),
DELETE_TOKENS_REQUEST_REJECTED("DeleteTokens request resulted in failure."),

// invoke connection interface
Expand Down
16 changes: 16 additions & 0 deletions common/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,22 @@ public void testNonJsonBodyFallsBackToRawBodyAsMessage() {
Assert.assertEquals("plain text error response", ex.getMessage());
}

@Test
public void testJsonBodyWithGenericApiErrorEnvelopeStillWorks() {
Map<String, List<String>> headers = new HashMap<>();
String json = "{\"error\":{\"grpc_code\":5,\"http_code\":404,"
+ "\"message\":\"Invalid request. Vault not found for vaultID: vault123. "
+ "Specify a valid vaultID.\",\"http_status\":\"Not Found\",\"details\":[]}}";
SkyflowException ex = new SkyflowException(404, new RuntimeException("fail"), headers, json);
Assert.assertEquals("Invalid request. Vault not found for vaultID: vault123. "
+ "Specify a valid vaultID.", ex.getMessage());
Assert.assertEquals(Integer.valueOf(5), ex.getGrpcCode());
Assert.assertEquals("Not Found", ex.getHttpStatus());
Assert.assertEquals(404, ex.getHttpCode());
Assert.assertNotNull(ex.getDetails());
Assert.assertEquals(0, ex.getDetails().size());
}

@Test
public void testNullBodyNullCauseMessageFallsBackToErrorOccurred() {
Map<String, List<String>> headers = new HashMap<>();
Expand Down
Loading
Loading