diff --git a/common/src/main/java/com/skyflow/logs/ErrorLogs.java b/common/src/main/java/com/skyflow/logs/ErrorLogs.java
index 921defaf..154c26e8 100644
--- a/common/src/main/java/com/skyflow/logs/ErrorLogs.java
+++ b/common/src/main/java/com/skyflow/logs/ErrorLogs.java
@@ -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."),
diff --git a/flowvault/pom.xml b/flowvault/pom.xml
index f9db081c..d9dd86f1 100644
--- a/flowvault/pom.xml
+++ b/flowvault/pom.xml
@@ -12,7 +12,7 @@
skyflow-flowvault-java
- 1.2.0-dev.14ede71e
+ 1.2.0-dev.68d5268c
jar
${project.groupId}:${project.artifactId}
Skyflow FlowVault SDK for the Java programming language
diff --git a/skyvault/api-report/skyflow-java.baseline.jar b/skyvault/api-report/skyflow-java.baseline.jar
index dc2ace2b..309482bf 100644
Binary files a/skyvault/api-report/skyflow-java.baseline.jar and b/skyvault/api-report/skyflow-java.baseline.jar differ
diff --git a/skyvault/src/main/java/com/skyflow/errors/ErrorMessage.java b/skyvault/src/main/java/com/skyflow/errors/ErrorMessage.java
index 16c3fcf4..66b3ddda 100644
--- a/skyvault/src/main/java/com/skyflow/errors/ErrorMessage.java
+++ b/skyvault/src/main/java/com/skyflow/errors/ErrorMessage.java
@@ -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."),
diff --git a/skyvault/src/main/java/com/skyflow/utils/validations/Validations.java b/skyvault/src/main/java/com/skyflow/utils/validations/Validations.java
index 6f87b2a6..09f7c47a 100644
--- a/skyvault/src/main/java/com/skyflow/utils/validations/Validations.java
+++ b/skyvault/src/main/java/com/skyflow/utils/validations/Validations.java
@@ -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 tokensMap = tokens.get(index);
HashMap valuesMap = values.get(index);
if (tokensMap == null || valuesMap == null) {
diff --git a/skyvault/src/test/java/com/skyflow/vault/data/InsertTests.java b/skyvault/src/test/java/com/skyflow/vault/data/InsertTests.java
index baa2d90d..d4773151 100644
--- a/skyvault/src/test/java/com/skyflow/vault/data/InsertTests.java
+++ b/skyvault/src/test/java/com/skyflow/vault/data/InsertTests.java
@@ -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);
@@ -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);
}
}