Skip to content

Commit dd1b623

Browse files
Fix _type deprecation on simulate pipeline API (#116259)
A change in 8.0.0 was intended to deprecate specifying `_type` in a document passed to the simulate pipeline API, unless it was in BWC mode for v7. There was a logic error which meant that the warning would actually *only* fire in BWC mode... except that the API version was not being correctly passed from the REST request to the transport request, so the warning would never fire. This change for the 9.0 release fixes both issues, so that the deprecation warning fires unless it is in BWC mode for v8.
1 parent dffe14f commit dd1b623

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

docs/changelog/116259.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pr: 116259
2+
summary: Fix `_type` deprecation on simulate pipeline API
3+
area: Ingest Node
4+
type: deprecation
5+
issues: []
6+
deprecation:
7+
title: Document `_type` deprecated on simulate pipeline API
8+
area: REST API
9+
details: >-
10+
Passing a document with a `_type` property is deprecated in the `/_ingest/pipeline/{id}/_simulate` and
11+
`/_ingest/pipeline/_simulate` APIs.
12+
impact: >-
13+
Users should already have stopped using mapping types, which were deprecated in {es} 7. This deprecation warning
14+
will fire if they specify mapping types on documents pass to the simulate pipeline API.

server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.elasticsearch.common.lucene.uid.Versions;
1919
import org.elasticsearch.common.xcontent.XContentHelper;
2020
import org.elasticsearch.core.RestApiVersion;
21+
import org.elasticsearch.core.UpdateForV10;
2122
import org.elasticsearch.index.VersionType;
2223
import org.elasticsearch.ingest.ConfigurationUtils;
2324
import org.elasticsearch.ingest.IngestDocument;
@@ -156,6 +157,7 @@ static Parsed parse(Map<String, Object> config, boolean verbose, IngestService i
156157
return new Parsed(pipeline, ingestDocumentList, verbose);
157158
}
158159

160+
@UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT) // Unconditionally deprecate the _type field once V8 BWC support is removed
159161
private static List<IngestDocument> parseDocs(Map<String, Object> config, RestApiVersion restApiVersion) {
160162
List<Map<String, Object>> docs = ConfigurationUtils.readList(null, null, config, Fields.DOCS);
161163
if (docs.isEmpty()) {
@@ -172,7 +174,7 @@ private static List<IngestDocument> parseDocs(Map<String, Object> config, RestAp
172174
String index = ConfigurationUtils.readStringOrIntProperty(null, null, dataMap, Metadata.INDEX.getFieldName(), "_index");
173175
String id = ConfigurationUtils.readStringOrIntProperty(null, null, dataMap, Metadata.ID.getFieldName(), "_id");
174176
String routing = ConfigurationUtils.readOptionalStringOrIntProperty(null, null, dataMap, Metadata.ROUTING.getFieldName());
175-
if (restApiVersion == RestApiVersion.V_7 && dataMap.containsKey(Metadata.TYPE.getFieldName())) {
177+
if (restApiVersion != RestApiVersion.V_8 && dataMap.containsKey(Metadata.TYPE.getFieldName())) {
176178
deprecationLogger.compatibleCritical(
177179
"simulate_pipeline_with_types",
178180
"[types removal] specifying _type in pipeline simulation requests is deprecated"

server/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public String getName() {
4747
@Override
4848
public RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
4949
Tuple<XContentType, BytesReference> sourceTuple = restRequest.contentOrSourceParam();
50-
SimulatePipelineRequest request = new SimulatePipelineRequest(sourceTuple.v2(), sourceTuple.v1());
50+
SimulatePipelineRequest request = new SimulatePipelineRequest(sourceTuple.v2(), sourceTuple.v1(), restRequest.getRestApiVersion());
5151
request.setId(restRequest.param("id"));
5252
request.setVerbose(restRequest.paramAsBoolean("verbose", false));
5353
return channel -> client.admin().cluster().simulatePipeline(request, new RestToXContentListener<>(channel));

0 commit comments

Comments
 (0)