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

[8.x] Handle both JSON and XJSON in processor editor (#200692) #201910

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

Closes [elastic#175753](elastic#175753)

## Summary
When a user creates a pipeline with a processor that has an JSON editor
field [Foreach, Grok, Inference, Redact and Script], our editor convert
the input to XJSON. This can be confused to the user, who see their
input modified without understanding the reason. For that, this PR
creates a new editor that handles both XJSON and JSON format and does
not changes the content that the user introduced while editing. Once the
pipeline is saved, it will always retrieve the parsed data.

I've created a whole new editor instead of modifying `XJsonEditor`
because the original one is still in use in the `Custom processor`. This
is because I've created [a
list](https://github.com/SoniaSanzV/kibana/blob/d7d5ecafa7dbae96fe52c2e37394520b6353bd92/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/utils.ts#L151-L157)
of the processor fields that needs to be serialized in
`convertProcessorInternalToProcessor`. Since we don't know the name of
the custom processor, we can't apply this workflow. I'm not super happy
with the idea of adding manually the names of the processors to a list.
I would like to have something more agnostic but I haven't come up with
a solution that allows me to do that without breaking other fields. So,
any suggestions are super welcome!

### How to test
Create one of the following processors: Foreach, Grok, Inference, Redact
or Script. In the JSON field, add a JSON with both with and without
escaped strings. While you are editing the processor before saving the
pipeline, you should see the processor as you typed it. In the `Show
Request` flyout, you should see the properly parsed JSON.

The pipeline should save with the correct parsed values and, once saved,
if you click update, you only will get parsed values.

### Demo

https://github.com/user-attachments/assets/1f9681df-2fb4-4ed5-ac30-03f2937abfe9
(cherry picked from commit 8839894)
@kibanamachine kibanamachine merged commit 9a76b27 into elastic:8.x Nov 27, 2024
11 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ingestPipelines 405.7KB 406.7KB +1.1KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
ingestPipelines 17.5KB 17.5KB -40.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
ingestPipelines 15 29 +14

Total ESLint disabled count

id before after diff
ingestPipelines 15 29 +14

cc @SoniaSanzV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants