Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase max doc length limit: 1M -> 4M #841

Merged
merged 4 commits into from
Jan 30, 2024
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
2 changes: 1 addition & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Here are some Stargate-relevant property groups that are necessary for correct s

| Property | Type | Default | Description |
|-----------------------------------------------------------------|-------|-------------|--------------------------------------------------------------------------------------|
| `stargate.jsonapi.document.limits.max-size` | `int` | `1_000_000` | The maximum size of (in characters) a single document. |
| `stargate.jsonapi.document.limits.max-size` | `int` | `4_000_000` | The maximum size of (in characters) a single document. |
| `stargate.jsonapi.document.limits.max-depth` | `int` | `16` | The maximum document depth (nesting). |
| `stargate.jsonapi.document.limits.max-property-name-length` | `int` | `100` | The maximum length of property names in a document for an individual segment. |
| `stargate.jsonapi.document.limits.max-property-path-length` | `int` | `250` | The maximum length of property paths in a document (segments and separating periods) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@ConfigMapping(prefix = "stargate.jsonapi.document.limits")
public interface DocumentLimitsConfig {
/** Defines the default maximum document size. */
int DEFAULT_MAX_DOCUMENT_SIZE = 1_000_000;
int DEFAULT_MAX_DOCUMENT_SIZE = 4_000_000;

/** Defines the default maximum document (nesting) depth */
int DEFAULT_MAX_DOCUMENT_DEPTH = 16;
Expand Down Expand Up @@ -57,7 +57,7 @@ public interface DocumentLimitsConfig {
int DEFAULT_MAX_VECTOR_EMBEDDING_LENGTH = 4096;

/**
* @return Defines the maximum document size, defaults to {@code 1 meg} (1 million characters).
* @return Defines the maximum document size, defaults to {@code 4 meg} (4 million characters).
*/
@Positive
@WithDefault("" + DEFAULT_MAX_DOCUMENT_SIZE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ public void tryInsertTooLongDoc() throws Exception {
.body("errors[0].errorCode", is("SHRED_DOC_LIMIT_VIOLATION"))
.body(
"errors[0].message", startsWith("Document size limitation violated: document size ("))
.body("errors[0].message", endsWith(") exceeds maximum allowed (1000000)"));
.body("errors[0].message", endsWith(") exceeds maximum allowed (4000000)"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ public class ShredderDocLimitsTest {
class ValidationDocSizeViolations {
@Test
public void allowBigButNotTooBigDoc() {
// Given we fail at 1 meg, let's try 800k (8 x 10 x 10k)
final ObjectNode bigDoc = createBigDoc(8, 10);
// Given we fail at 4 meg
// let's try 600k (8 x 5 x 7.5k)
final ObjectNode bigDoc = createBigDoc(8, 5);
assertThat(shredder.shred(bigDoc)).isNotNull();

// let's also try 1m (12 x 12 x 7.5k)
final ObjectNode bigDoc1m = createBigDoc(12, 12);
assertThat(shredder.shred(bigDoc1m)).isNotNull();
}

@Test
public void catchTooBigDoc() {
// Let's construct document above 1 meg limit (but otherwise legal), with
// 144 x 7.5k String values, divided in 12 sub documents of 12 properties
final ObjectNode bigDoc = createBigDoc(12, 12);
// Let's construct document above 4 meg limit (but otherwise legal), with
// (12x45) x 7.5k String values, divided in 12 sub documents of 45 properties
final ObjectNode bigDoc = createBigDoc(12, 45);

Exception e = catchException(() -> shredder.shred(bigDoc));
assertThat(e)
Expand Down
Loading