From 1140ebf4d4635b9bae9011b47156e29abd66ff86 Mon Sep 17 00:00:00 2001 From: Jared Tan Date: Mon, 25 Nov 2019 02:07:11 +0800 Subject: [PATCH] Include id to the error msg when it's too long (#49433) --- .../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 96cc3624a3432..0f95239f06cac 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -198,7 +198,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); } 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() {