From 7edb978256efe52cf0a250534f509eec3bbd1b19 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Wed, 31 Jan 2018 09:21:09 +0100 Subject: [PATCH] RandomDocumentPicks#randomFieldName can produce invalid field name (#28419) This change makes sure that this function does not create field names that end with a '.', more precisely it only allows alpha-numeric characters to compose the leaf field name. Closes #27373 --- .../java/org/elasticsearch/ingest/RandomDocumentPicks.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/framework/src/main/java/org/elasticsearch/ingest/RandomDocumentPicks.java b/test/framework/src/main/java/org/elasticsearch/ingest/RandomDocumentPicks.java index c067f261051..0def04a79ea 100644 --- a/test/framework/src/main/java/org/elasticsearch/ingest/RandomDocumentPicks.java +++ b/test/framework/src/main/java/org/elasticsearch/ingest/RandomDocumentPicks.java @@ -43,12 +43,16 @@ public final class RandomDocumentPicks { public static String randomFieldName(Random random) { int numLevels = RandomNumbers.randomIntBetween(random, 1, 5); StringBuilder fieldName = new StringBuilder(); - for (int i = 0; i < numLevels; i++) { + for (int i = 0; i < numLevels-1; i++) { if (i > 0) { fieldName.append('.'); } fieldName.append(randomString(random)); } + if (numLevels > 1) { + fieldName.append('.'); + } + fieldName.append(randomLeafFieldName(random)); return fieldName.toString(); }