From 1d2bfd1af68a15b7e2b29c6d5983f88cc40efdb1 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 54f19431ef82e..e01fc7768cf32 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -242,7 +242,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 e01cc511ba136..aa906331943d1 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() {