Skip to content

Commit d6a49b3

Browse files
Updating error message for runtime and multi field type parser
1 parent a797e8e commit d6a49b3

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

server/src/main/java/org/elasticsearch/index/mapper/RuntimeField.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,11 @@ static Map<String, RuntimeField> parseRuntimeFields(
179179
}
180180
Parser typeParser = parserContext.runtimeFieldParser(type);
181181
if (typeParser == null) {
182-
throw new MapperParsingException("No handler for type [" + type + "] declared on runtime field [" + fieldName + "]");
182+
throw new MapperParsingException(
183+
"The mapper type [" + type + "] declared on field [" + fieldName + "] does not exist."
184+
+ " It might have been created within a future version or requires a plugin to be installed."
185+
+ " Check the documentation."
186+
);
183187
}
184188
runtimeFields.put(fieldName, builder.apply(typeParser.parse(fieldName, propNode, parserContext)));
185189
propNode.remove("type");

server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ public static boolean parseMultiField(
161161

162162
Mapper.TypeParser typeParser = parserContext.typeParser(type);
163163
if (typeParser == null) {
164-
throw new MapperParsingException("no handler for type [" + type + "] declared on field [" + multiFieldName + "]");
164+
throw new MapperParsingException(
165+
"The mapper type [" + type + "] declared on field [" + multiFieldName + "] does not exist."
166+
+ " It might have been created within a future version or requires a plugin to be installed."
167+
+ " Check the documentation."
168+
);
165169
}
166170
if (typeParser instanceof FieldMapper.TypeParser == false) {
167171
throw new MapperParsingException("Type [" + type + "] cannot be used in multi field");

server/src/test/java/org/elasticsearch/index/mapper/RootObjectMapperTests.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,19 @@ public void testRuntimeSectionMerge() throws IOException {
313313
public void testRuntimeSectionNonRuntimeType() throws IOException {
314314
XContentBuilder mapping = runtimeFieldMapping(builder -> builder.field("type", "unknown"));
315315
MapperParsingException e = expectThrows(MapperParsingException.class, () -> createMapperService(mapping));
316-
assertEquals("Failed to parse mapping: No handler for type [unknown] declared on runtime field [field]", e.getMessage());
316+
assertEquals("Failed to parse mapping: The mapper type [unknown] declared on field [field] does not exist."
317+
+ " It might have been created within a future version or requires a plugin to be installed. Check the documentation.",
318+
e.getMessage()
319+
);
317320
}
318321

319322
public void testRuntimeSectionHandlerNotFound() throws IOException {
320323
XContentBuilder mapping = runtimeFieldMapping(builder -> builder.field("type", "unknown"));
321324
MapperParsingException e = expectThrows(MapperParsingException.class, () -> createMapperService(mapping));
322-
assertEquals("Failed to parse mapping: No handler for type [unknown] declared on runtime field [field]", e.getMessage());
325+
assertEquals("Failed to parse mapping: The mapper type [unknown] declared on field [field] does not exist."
326+
+ " It might have been created within a future version or requires a plugin to be installed. Check the documentation.",
327+
e.getMessage()
328+
);
323329
}
324330

325331
public void testRuntimeSectionMissingType() throws IOException {

0 commit comments

Comments
 (0)