Skip to content

Commit

Permalink
Fix #713: change max-String-value length from 16,000 to 8,000 (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
tatu-at-datastax authored Dec 8, 2023
1 parent 3fb1519 commit ddc40f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
10 changes: 4 additions & 6 deletions docs/jsonapi-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,17 +408,15 @@ has 3 fields: `root`, `root.branch`, and `root.branch.leaf`, for purposes of thi

The maximum size of field values are:

| JSON Type | Maximum Value |
|-----------|---------------------------------------------|
| `string` | Maximum length of 16,000 unicode characters |
| `number` | Maximum length of 50 number characters |

| JSON Type | Maximum Value |
|-----------|--------------------------------------------|
| `string` | Maximum length of 8,000 unicode characters |
| `number` | Maximum length of 50 number characters |

#### Document Array Limits

The maximum length of an array is 100 elements.


### Equality handling with arrays and subdocs

Given the query `{"foo" : "bar"}`, this matches:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ public interface DocumentLimitsConfig {
/** Defines the maximum length of property names in JSON documents */
int DEFAULT_MAX_PROPERTY_NAME_LENGTH = 48;

/** Defines the default maximum length of a single String value */
int DEFAULT_MAX_STRING_LENGTH = 16_000;
/**
* Defines the default maximum length of a single String value: 8,000 characters with 1.0.0-BETA-6
* and later (16,000 before)
*/
int DEFAULT_MAX_STRING_LENGTH = 8_000;

/**
* @return Defines the maximum document size, defaults to {@code 1 meg} (1 million characters).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public void allowBigButNotTooBigDoc() {
@Test
public void catchTooBigDoc() {
// Let's construct document above 1 meg limit (but otherwise legal), with
// 100 x 10k String values, divided in 10 sub documents of 10 properties
final ObjectNode bigDoc = createBigDoc(10, 10);
// 144 x 7.5k String values, divided in 12 sub documents of 12 properties
final ObjectNode bigDoc = createBigDoc(12, 12);

Exception e = catchException(() -> shredder.shred(bigDoc));
assertThat(e)
Expand All @@ -63,7 +63,7 @@ private ObjectNode createBigDoc(int mainProps, int subProps) {
for (int ix1 = 0; ix1 < mainProps; ++ix1) {
ObjectNode mainProp = bigDoc.putObject("prop" + ix1);
for (int ix2 = 0; ix2 < subProps; ++ix2) {
mainProp.put("sub" + ix2, RandomStringUtils.randomAscii(10_000));
mainProp.put("sub" + ix2, RandomStringUtils.randomAscii(7_500));
}
}
return bigDoc;
Expand Down Expand Up @@ -243,7 +243,7 @@ public void allowNotTooLongStringValues() {
final ObjectNode doc = objectMapper.createObjectNode();
doc.put("_id", 123);
// Max is 16_000 so do a bit less
doc.put("text", RandomStringUtils.randomAscii(12_000));
doc.put("text", RandomStringUtils.randomAscii(7_500));
assertThat(shredder.shred(doc)).isNotNull();
}

Expand Down

0 comments on commit ddc40f4

Please sign in to comment.