Skip to content

Commit 70a79bc

Browse files
authored
Prevent passing a pipeline to a logs stream index request (#137992)
1 parent 7c9aea7 commit 70a79bc

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

docs/changelog/137992.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 137992
2+
summary: Prevent passing a pipeline to a logs stream bulk index request body
3+
area: Data streams
4+
type: bug
5+
issues: []
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
teardown:
3+
- do:
4+
streams.logs_disable: { }
5+
6+
---
7+
"Check User Can't Provide Pipeline to Logs Stream":
8+
- do:
9+
streams.logs_enable: { }
10+
- is_true: acknowledged
11+
12+
- do:
13+
streams.status: { }
14+
- is_true: logs.enabled
15+
16+
- do:
17+
bulk:
18+
index: logs
19+
body: |
20+
{ "create": {"pipeline": "noop"}}
21+
{ "message": "hello streams!"}
22+
- match: { errors: true }
23+
- match: { items.0.create.status: 400 }
24+
- match: { items.0.create.error.type: "illegal_argument_exception" }
25+
- match: { items.0.create.error.reason: "Cannot provide a pipeline when writing to a stream however the [noop] pipeline was provided when writing to the [logs] stream" }

server/src/main/java/org/elasticsearch/action/bulk/TransportAbstractBulkAction.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,16 @@ private void doStreamsChecks(
476476
+ "] stream instead"
477477
);
478478
}
479-
479+
if (e == null && streamType.getStreamName().equals(ir.index()) && ir.getPipeline() != null) {
480+
e = new IllegalArgumentException(
481+
"Cannot provide a pipeline when writing to a stream "
482+
+ "however the ["
483+
+ ir.getPipeline()
484+
+ "] pipeline was provided when writing to the ["
485+
+ streamType.getStreamName()
486+
+ "] stream"
487+
);
488+
}
480489
if (e == null && streamsRestrictedParamsUsed(bulkRequest) && req.index().equals(streamType.getStreamName())) {
481490
e = new IllegalArgumentException(
482491
"When writing to a stream, only the following parameters are allowed: ["

0 commit comments

Comments
 (0)