Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block storing invalid pipeline configs caused by nested processors #93425

Closed

Conversation

mattc58
Copy link
Contributor

@mattc58 mattc58 commented Feb 1, 2023

This fixes #41837 by blocking PUT _ingest/pipeline or POST _ingest/pipeline/_simulate calls if there is are nested processors in any of the processor configs.

It will not do anything to pipelines with nested processors which have already been stored in the server. The behavior of those pipelines will remain as they are before this change (which is to say, non-deterministic in their processing order based on the use of HashMap for their storage).

@mattc58 mattc58 added Team:Data Management Meta label for data/management team and removed v8.7.0 labels Feb 1, 2023
@mattc58 mattc58 requested a review from joegallo February 1, 2023 17:34
@mattc58 mattc58 added the v8.7.0 label Feb 1, 2023
@@ -36,6 +36,8 @@
import java.util.Objects;

public class SimulatePipelineRequest extends ActionRequest implements ToXContentObject {
public static final String PROCESSORS_KEY = "processors";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this variable is never used.


import static org.elasticsearch.rest.RestRequest.Method.PUT;

public class RestPutPipelineAction extends BaseRestHandler {
public static final String PROCESSORS_KEY = "processors";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this variable is never used.

String fieldName = randomAlphaOfLengthBetween(1, 10);
String fieldValue = randomAlphaOfLengthBetween(1, 10);
Map<String, Object> doc = new HashMap<>();
doc.put(Fields.SOURCE, Collections.singletonMap(fieldName, fieldValue));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer Map.of(...) rather than Collections.singletonMap(...) where possible -- there's this line and another a few lines below.

Map<String, Object> requestContent = new HashMap<>();
Map<String, Object> pipelineConfig = new HashMap<>();
List<Map<String, Object>> processors = new ArrayList<>();
Map<String, Object> processorConfig = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd declare the processorConfig right before you use it, slightly clearer that way.

@@ -53,6 +53,32 @@ public void testCreate() throws Exception {
assertThat(pipeline.getProcessors().get(1).getTag(), nullValue());
}

public void testContainsNestedProcessors() throws Exception {
// create a pipeline with non-nested processors
Map<String, Object> processorConfig0 = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd drop processorConfig0 and processorConfig1, I don't think they carry their weight as variables. Probably just replace new HashMap<>() at each of their current uses.

@joegallo
Copy link
Contributor

joegallo commented Feb 7, 2023

Nits aside, mostly looks pretty good to me! What's the word on how we're going to treat this -- e.g. as a bugfix with no warnings, or as a breaking change with a deprecation period or the like?

@rjernst rjernst added v8.8.0 and removed v8.7.0 labels Feb 8, 2023
@gmarouli gmarouli added v8.9.0 and removed v8.8.0 labels Apr 26, 2023
@quux00 quux00 added v8.11.0 and removed v8.10.0 labels Aug 16, 2023
@mattc58 mattc58 added v8.12.0 and removed v8.11.0 labels Oct 4, 2023
@mattc58
Copy link
Contributor Author

mattc58 commented Oct 26, 2023

Closing this until it's prioritized again

@mattc58 mattc58 closed this Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Data Management Meta label for data/management team v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An invalid pipeline can be stored
7 participants