Skip to content
Merged
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
1 change: 0 additions & 1 deletion common/src/main/java/com/skyflow/logs/ErrorLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public enum ErrorLogs {
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."),
TOKENS_VALUES_SIZE_MISMATCH("Invalid %s1 request. 'tokens' contains more entries than 'values'."),
NULL_TOKENS_OR_VALUES_ENTRY("Invalid %s1 request. Entry in 'tokens' or 'values' can not be null at index %s2."),
EMPTY_UPSERT("Invalid %s1 request. Upsert can not be empty."),
INVALID_UPSERT_UPDATE_TYPE("Invalid %s1 request. Upsert updateType must be either UPDATE or REPLACE."),
Expand Down
2 changes: 1 addition & 1 deletion flowvault/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</parent>

<artifactId>skyflow-flowvault-java</artifactId>
<version>1.2.0-dev.14ede71e</version>
<version>1.2.0-dev.68d5268c</version>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>Skyflow FlowVault SDK for the Java programming language</description>
Expand Down
Binary file modified skyvault/api-report/skyflow-java.baseline.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public enum ErrorMessage {
NoTokensWithTokenMode("%s0 Validation error. Tokens weren't specified for records while 'tokenMode' was %s1. Specify tokens."),
MismatchOfFieldsAndTokens("%s0 Validation error. 'fields' and 'tokens' have different columns names. Verify that 'fields' and 'tokens' columns match."),
InsufficientTokensPassedForTokenModeEnableStrict("%s0 Validation error. 'tokenMode' is set to 'ENABLE_STRICT', but some fields are missing tokens. Specify tokens for all fields."),
TokensValuesSizeMismatch("%s0 Validation error. 'tokens' contains more entries than 'values'. Specify at most one tokens entry per values entry."),
NullTokensOrValuesEntry("%s0 Validation error. Entry in 'tokens' or 'values' is null. Specify a valid entry."),
BatchInsertPartialSuccess("%s0 Insert operation completed with partial success."),
BatchInsertFailure("%s0 Insert operation failed."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,17 +771,13 @@ private static void validateTokensForInsertRequest(
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokens.getMessage());
}

// Fewer token maps than records is allowed for ENABLE (the server validates record by record, and
// continueOnError inserts the records that have tokens), matching the Node, Go and Python SDKs.
// ENABLE_STRICT already requires equal counts in validateInsertRequest. More token maps than records
// can never be paired, so it is rejected here instead of failing with IndexOutOfBoundsException.
for (int index = 0; index < tokens.size(); index++) {
if (index >= values.size()) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.TOKENS_VALUES_SIZE_MISMATCH.getLog(), InterfaceName.INSERT.getName()
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.TokensValuesSizeMismatch.getMessage());
}
// Only the token maps that pair with a record are validated, as in the Node, Go and Python SDKs.
// Fewer token maps than records is allowed for ENABLE: the server validates record by record, and
// continueOnError inserts the records that have tokens. ENABLE_STRICT already requires equal
// counts in validateInsertRequest. Bounding the loop by both lists is what prevents the
// IndexOutOfBoundsException that 2.1.1 threw when tokens outnumbered values.
int pairedEntries = Math.min(tokens.size(), values.size());
for (int index = 0; index < pairedEntries; index++) {
HashMap<String, Object> tokensMap = tokens.get(index);
HashMap<String, Object> valuesMap = values.get(index);
if (tokensMap == null || valuesMap == null) {
Expand Down
11 changes: 4 additions & 7 deletions skyvault/src/test/java/com/skyflow/vault/data/InsertTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ public void testFewerTokensThanValuesIsAllowedWithTokenModeEnableInInsertRequest
}

@Test
public void testMoreTokensThanValuesIsRejectedWithTokenModeEnableInInsertRequestValidations() {
public void testMoreTokensThanValuesDoesNotThrowWithTokenModeEnableInInsertRequestValidations() {
// 2.1.1 threw IndexOutOfBoundsException here; only paired entries are validated now and the
// server decides about the surplus, as in the Node and Python SDKs.
values.add(valueMap);
tokens.add(tokenMap);
tokens.add(tokenMap);
Expand All @@ -451,13 +453,8 @@ public void testMoreTokensThanValuesIsRejectedWithTokenModeEnableInInsertRequest
.build();
try {
Validations.validateInsertRequest(request);
Assert.fail(EXCEPTION_NOT_THROWN);
} catch (SkyflowException e) {
Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode());
Assert.assertEquals(
Utils.parameterizedString(ErrorMessage.TokensValuesSizeMismatch.getMessage(), Constants.SDK_PREFIX),
e.getMessage()
);
Assert.fail(INVALID_EXCEPTION_THROWN);
}
}

Expand Down
Loading