From 8622a9887cffec0c1273f8291456f411e88c2428 Mon Sep 17 00:00:00 2001 From: "Jared.Tan" Date: Thu, 21 Nov 2019 20:50:34 +0800 Subject: [PATCH 1/2] print id detail when id is too long. --- .../main/java/org/elasticsearch/action/index/IndexRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 87866de8ab3eb..39289b398fa6f 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -194,7 +194,7 @@ public ActionRequestValidationException validate() { validationException = DocWriteRequest.validateSeqNoBasedCASParams(this, 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: " + + validationException = addValidationError("id:" + id + " is too long, must be no longer than 512 bytes but was: " + id.getBytes(StandardCharsets.UTF_8).length, validationException); } From f3c424f0d2d53aa2b12c531118ac593d24dde74e Mon Sep 17 00:00:00 2001 From: "Jared.Tan" Date: Sat, 23 Nov 2019 21:54:52 +0800 Subject: [PATCH 2/2] update format. --- .../main/java/org/elasticsearch/action/index/IndexRequest.java | 2 +- .../java/org/elasticsearch/action/index/IndexRequestTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 39289b398fa6f..2e917a178c62f 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -194,7 +194,7 @@ public ActionRequestValidationException validate() { validationException = DocWriteRequest.validateSeqNoBasedCASParams(this, validationException); if (id != null && id.getBytes(StandardCharsets.UTF_8).length > 512) { - validationException = addValidationError("id:" + id + " is too long, must be no longer than 512 bytes but was: " + + validationException = addValidationError("id [" + id + "] is too long, must be no longer than 512 bytes but was: " + id.getBytes(StandardCharsets.UTF_8).length, validationException); } diff --git a/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java b/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java index 9d8518f23d750..21c56c7a3aa02 100644 --- a/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java @@ -102,7 +102,7 @@ public void testIndexingRejectsLongIds() { validate = request.validate(); assertThat(validate, notNullValue()); assertThat(validate.getMessage(), - containsString("id is too long, must be no longer than 512 bytes but was: 513")); + containsString("id [" + id + "] is too long, must be no longer than 512 bytes but was: 513")); } public void testWaitForActiveShards() {