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

[Form lib] Fix issue where serializer on fields are called on every change #75166

Conversation

sebelga
Copy link
Contributor

@sebelga sebelga commented Aug 17, 2020

This PR fixes an issue on the form lib where a serializer declared on a FieldConfig was called on every value change. This was not intended, as serializers could potentially be expensive (e.g. JSON.parse) and should only be called when building the form data. (calling form.submit() or form.getFormData()).

This could have an impact on our current forms using the <FormDataProvider /> as now with this PR, the value returned is not going through the serializer anymore and might defer from what the consumer expects. I have checked in the 3 plugins (index_management, ingest_pipline, security_solution) and I only found 1 potential risk of regression: in the "security_solution" plugin.

https://github.com/elastic/kibana/blob/master/x-pack/plugins/security_solution/public/detections/components/rules/step_about_rule/schema.tsx#L126

@elastic/siem-security-team Can you let me know if it is expected to convert the string to a number on every field value change? I will then have to update the code to use a formatter. (like we do here: https://github.com/elastic/kibana/blob/master/x-pack/plugins/index_management/public/application/components/component_templates/component_template_wizard/component_template_form/steps/step_logistics_schema.tsx#L64)

Fixes #74948

We want to have the guarantee that when the serializers are called, the form is valid (all the fields value are valid). This would prevent for example a serializer to execute a JSON.parse() on a string that is not valid JSON.
@sebelga sebelga requested a review from a team as a code owner August 17, 2020 14:30
@sebelga sebelga added release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.10.0 v8.0.0 labels Aug 17, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

@sebelga great work! 🍻

I tested with ingest processor forms locally and they are working as expected.

@sebelga
Copy link
Contributor Author

sebelga commented Aug 18, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

async chunks size

id value diff baseline
indexManagement 1.5MB +3.7KB 1.5MB

page load bundle size

id value diff baseline
esUiShared 987.2KB -119.0B 987.3KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@sebelga
Copy link
Contributor Author

sebelga commented Aug 18, 2020

Thanks for the review @jloleysens !

@sebelga sebelga merged commit 196cb7f into elastic:master Aug 18, 2020
@sebelga sebelga deleted the bug/form-lib-call-serializer-only-when-building-object branch August 18, 2020 14:05
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 18, 2020
* master:
  Skip failing test in CI (elastic#75266)
  [Task Manager] time out work when it overruns in poller (elastic#74980)
  [Drilldowns] misc improvements & fixes (elastic#75276)
  Small README note on bumping memory for builds (elastic#75247)
  [Security Solution][Detections] Adds exception modal tests (elastic#74596)
  [Dashboard] Sample data link does not work (elastic#75262)
  [Dashboard First] Unlink from Library Action With ReferenceOrValueEmbeddable (elastic#74905)
  [Form lib] Fix issue where serializer on fields are called on every change (elastic#75166)
  convert processor labels to sentence case (elastic#75278)
  [Monaco] Refactor the way XJSON grammar checker gets registered (elastic#75160)
  Clarify no documents error message when filtering by is_training (elastic#75227)
  [Lens] Fix crash when two layers xychart  switches to pie (elastic#75267)
  [Observability Homepage] Fix console error because of side effect (elastic#75258)
  [Usage Collection] Add `legacy=true` option to the /api/stats request in the docs (elastic#75146)
  [ML] Functional tests - re-activate DFA test suites (elastic#75257)
  GS providers improvements (elastic#75174)
  [Visualize] First version of by-value visualize editor (elastic#72256)
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 19, 2020
…emove-header

* saved-objects/version-on-create: (59 commits)
  remove version when loading sample data
  omit version from SO import/export
  Skip failing test in CI (elastic#75266)
  [Task Manager] time out work when it overruns in poller (elastic#74980)
  [Drilldowns] misc improvements & fixes (elastic#75276)
  Small README note on bumping memory for builds (elastic#75247)
  [Security Solution][Detections] Adds exception modal tests (elastic#74596)
  Revert "Revert "added missing core docs""
  Revert "Revert "added version to saved object bulk creation""
  [Dashboard] Sample data link does not work (elastic#75262)
  [Dashboard First] Unlink from Library Action With ReferenceOrValueEmbeddable (elastic#74905)
  [Form lib] Fix issue where serializer on fields are called on every change (elastic#75166)
  convert processor labels to sentence case (elastic#75278)
  [Monaco] Refactor the way XJSON grammar checker gets registered (elastic#75160)
  Clarify no documents error message when filtering by is_training (elastic#75227)
  [Lens] Fix crash when two layers xychart  switches to pie (elastic#75267)
  [Observability Homepage] Fix console error because of side effect (elastic#75258)
  [Usage Collection] Add `legacy=true` option to the /api/stats request in the docs (elastic#75146)
  [ML] Functional tests - re-activate DFA test suites (elastic#75257)
  GS providers improvements (elastic#75174)
  ...
sebelga added a commit that referenced this pull request Aug 19, 2020
…very change (#75166) (#75355)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Form lib] Only call the field serializer when outputting the form data
4 participants