Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/96941.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 96941
summary: Trim field references in reroute processor
area: Ingest Node
type: bug
issues:
- 96939
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ private DataStreamValueSource(String value, Function<String, String> sanitizer)
if (fieldReference.startsWith("{") && fieldReference.endsWith("}")) {
fieldReference = fieldReference.substring(1, fieldReference.length() - 1);
}
fieldReference = fieldReference.trim();
// only a single field reference is allowed
// so something like this is disallowed: {{foo}}-{{bar}}
if (fieldReference.contains("{") || fieldReference.contains("}")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void testEventDataset() throws Exception {
IngestDocument ingestDocument = createIngestDocument("logs-generic-default");
ingestDocument.setFieldValue("event.dataset", "foo");

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

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

RerouteProcessor processor = createRerouteProcessor(List.of("{{ds}}"), List.of());
RerouteProcessor processor = createRerouteProcessor(List.of("{{ ds }}"), List.of());
processor.execute(ingestDocument);
assertDataSetFields(ingestDocument, "logs", "foo", "default");
assertFalse(ingestDocument.hasField("event.dataset"));
Expand Down