Skip to content

Commit f69094f

Browse files
authored
Trim field references in reroute processor (#96941)
1 parent 0bd1803 commit f69094f

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

docs/changelog/96941.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 96941
2+
summary: Trim field references in reroute processor
3+
area: Ingest Node
4+
type: bug
5+
issues:
6+
- 96939

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/RerouteProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ private DataStreamValueSource(String value, Function<String, String> sanitizer)
240240
if (fieldReference.startsWith("{") && fieldReference.endsWith("}")) {
241241
fieldReference = fieldReference.substring(1, fieldReference.length() - 1);
242242
}
243+
fieldReference = fieldReference.trim();
243244
// only a single field reference is allowed
244245
// so something like this is disallowed: {{foo}}-{{bar}}
245246
if (fieldReference.contains("{") || fieldReference.contains("}")) {

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RerouteProcessorTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void testEventDataset() throws Exception {
3535
IngestDocument ingestDocument = createIngestDocument("logs-generic-default");
3636
ingestDocument.setFieldValue("event.dataset", "foo");
3737

38-
RerouteProcessor processor = createRerouteProcessor(List.of("{{event.dataset}}"), List.of());
38+
RerouteProcessor processor = createRerouteProcessor(List.of("{{event.dataset }}"), List.of());
3939
processor.execute(ingestDocument);
4040
assertDataSetFields(ingestDocument, "logs", "foo", "default");
4141
assertThat(ingestDocument.getFieldValue("event.dataset", String.class), equalTo("foo"));
@@ -45,7 +45,7 @@ public void testEventDatasetDottedFieldName() throws Exception {
4545
IngestDocument ingestDocument = createIngestDocument("logs-generic-default");
4646
ingestDocument.getCtxMap().put("event.dataset", "foo");
4747

48-
RerouteProcessor processor = createRerouteProcessor(List.of("{{event.dataset}}"), List.of());
48+
RerouteProcessor processor = createRerouteProcessor(List.of("{{ event.dataset}}"), List.of());
4949
processor.execute(ingestDocument);
5050
assertDataSetFields(ingestDocument, "logs", "foo", "default");
5151
assertThat(ingestDocument.getCtxMap().get("event.dataset"), equalTo("foo"));
@@ -56,7 +56,7 @@ public void testNoDataset() throws Exception {
5656
IngestDocument ingestDocument = createIngestDocument("logs-generic-default");
5757
ingestDocument.setFieldValue("ds", "foo");
5858

59-
RerouteProcessor processor = createRerouteProcessor(List.of("{{ds}}"), List.of());
59+
RerouteProcessor processor = createRerouteProcessor(List.of("{{ ds }}"), List.of());
6060
processor.execute(ingestDocument);
6161
assertDataSetFields(ingestDocument, "logs", "foo", "default");
6262
assertFalse(ingestDocument.hasField("event.dataset"));

0 commit comments

Comments
 (0)