Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ingest Pipelines] Fix gsub processor's replacement field serializati…
…on (#175832) Fixes #170904 ## Summary This PR adds serialization to the `replacement` field in the Gsub processor edit form so that the field renders the text the way it is provided in the Es request, with unescaped special characters, if any exist. For example, we want `\n` to render the same, not to render as a new line (empty string) in the `replacement` field in the UI. ### Testing **Deserialization:** 1. Open Dev tools and create an ingest pipeline: ``` PUT _ingest/pipeline/my_pipeline_1 { "description": "My test pipeline", "processors": [ { "gsub": { "field": "message", "pattern": "\\\\n", "replacement": "\n" } }] } ``` 3. Run `GET _ingest/pipeline/my_pipeline_1` and observe the `replacement` fields (should be displayed as a new line). 4. Go to Stack Management -> Ingest Pipelines and start editing `my_pipeline_1`. The `replacement` field in the edit form should render as `\n` instead of an empty string. **Serialization:** 1. Go to Stack Management -> Ingest Pipelines and create a new pipeline `my_pipeline_2` with a Gsub processor on the field `message`, pattern: `\\\\n`, and replacement: `\n`. Save the pipeline 2. Go to Dev tools and get the pipeline: `GET _ingest/pipeline/my_pipeline_2`. The `replacement` field in the response should be displayed as a new line: ``` { "my_pipeline": { "description": "My test pipeline", "processors": [ { "gsub": { "field": "message", "pattern": """\\n""", "replacement": """ """ } } ] } } ``` 3. Edit the pipeline in the UI and change the `replacement` field to `\\n`. 4. Now the response in Dev tools should display `\n` (the new line character was escaped). You can also test with other escape characters. For example, creating a pipeline with a `my\ttab` replacement field in the UI should display `my tab` in the response.
- Loading branch information