Merge remote-tracking branch 'dakrone/limit-id-len'
This commit is contained in:
commit
2ab91f723c
|
@ -215,6 +215,11 @@ public class IndexRequest extends ReplicationRequest<IndexRequest> implements Do
|
||||||
validationException = addValidationError("ttl must not be negative", validationException);
|
validationException = addValidationError("ttl must not be negative", validationException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id != null && id.getBytes(StandardCharsets.UTF_8).length > 512) {
|
||||||
|
validationException = addValidationError("id is too long, must be no longer than 512 bytes but was: " +
|
||||||
|
id.getBytes(StandardCharsets.UTF_8).length, validationException);
|
||||||
|
}
|
||||||
return validationException;
|
return validationException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,28 @@ public class IndexRequestTests extends ESTestCase {
|
||||||
assertThat(request.validate().validationErrors(), not(empty()));
|
assertThat(request.validate().validationErrors(), not(empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testIndexingRejectsLongIds() {
|
||||||
|
String id = randomAsciiOfLength(511);
|
||||||
|
IndexRequest request = new IndexRequest("index", "type", id);
|
||||||
|
request.source("{}");
|
||||||
|
ActionRequestValidationException validate = request.validate();
|
||||||
|
assertNull(validate);
|
||||||
|
|
||||||
|
id = randomAsciiOfLength(512);
|
||||||
|
request = new IndexRequest("index", "type", id);
|
||||||
|
request.source("{}");
|
||||||
|
validate = request.validate();
|
||||||
|
assertNull(validate);
|
||||||
|
|
||||||
|
id = randomAsciiOfLength(513);
|
||||||
|
request = new IndexRequest("index", "type", id);
|
||||||
|
request.source("{}");
|
||||||
|
validate = request.validate();
|
||||||
|
assertThat(validate, notNullValue());
|
||||||
|
assertThat(validate.getMessage(),
|
||||||
|
containsString("id is too long, must be no longer than 512 bytes but was: 513"));
|
||||||
|
}
|
||||||
|
|
||||||
public void testSetTTLAsTimeValue() {
|
public void testSetTTLAsTimeValue() {
|
||||||
IndexRequest indexRequest = new IndexRequest();
|
IndexRequest indexRequest = new IndexRequest();
|
||||||
TimeValue ttl = TimeValue.parseTimeValue(randomTimeValue(), null, "ttl");
|
TimeValue ttl = TimeValue.parseTimeValue(randomTimeValue(), null, "ttl");
|
||||||
|
|
|
@ -97,6 +97,11 @@ characteristics as the former `scan` search type.
|
||||||
[[breaking_30_rest_api_changes]]
|
[[breaking_30_rest_api_changes]]
|
||||||
=== REST API changes
|
=== REST API changes
|
||||||
|
|
||||||
|
==== id values longer than 512 bytes are rejected
|
||||||
|
|
||||||
|
When specifying an `_id` value longer than 512 bytes, the request will be
|
||||||
|
rejected.
|
||||||
|
|
||||||
==== search exists api removed
|
==== search exists api removed
|
||||||
|
|
||||||
The search exists api has been removed in favour of using the search api with
|
The search exists api has been removed in favour of using the search api with
|
||||||
|
|
|
@ -24,3 +24,11 @@
|
||||||
- match: { _id: "1"}
|
- match: { _id: "1"}
|
||||||
- match: { _version: 1}
|
- match: { _version: 1}
|
||||||
- match: { _source: { foo: bar }}
|
- match: { _source: { foo: bar }}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
catch: request
|
||||||
|
index:
|
||||||
|
index: idx
|
||||||
|
type: type
|
||||||
|
id: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
body: { foo: bar }
|
||||||
|
|
Loading…
Reference in New Issue