[Streams] Schema Editor advanced field mapping options#210667
[Streams] Schema Editor advanced field mapping options#210667Kerry350 merged 9 commits intoelastic:mainfrom
Conversation
tonyghiani
left a comment
There was a problem hiding this comment.
Overall looks good, I left some minor notes on the code.
Regarding the additionalProperties vs top-level props, I like the separation of concerns as well, but this introduce potentially a de-sync between the stream and the component template.
For instance, a type defined in the additional properties (copy/paste, human error...) would override the defined type from the selector on the component template, and the user might never notice since the accordion is closed and the stored type in the stream remain the selector one.
As per following screenshot, the stream field would be:
{
"type": "ip",
"additionalProperties": {
"type": "keyword"
}
}
while in the component template it will be
{
"host.ip": {
"type": "keyword"
}
}
It might be worth excluding the type from the additionalProperties, wdyt?
A last note: when the additional properties have an unacceptable property, the error report is not very helpful, although we get the ES error message in the response, we can we pass it correctly into the error toast for a better feedback.

x-pack/solutions/observability/packages/kbn-streams-schema/src/models/ingest/fields/index.ts
Outdated
Show resolved
Hide resolved
x-pack/solutions/observability/packages/kbn-streams-schema/src/models/ingest/fields/index.ts
Outdated
Show resolved
Hide resolved
...tions/observability/plugins/streams/server/lib/streams/component_templates/generate_layer.ts
Outdated
Show resolved
Hide resolved
...lugins/streams_app/public/components/schema_editor/flyout/advanced_field_mapping_options.tsx
Outdated
Show resolved
Hide resolved
...lugins/streams_app/public/components/schema_editor/flyout/advanced_field_mapping_options.tsx
Outdated
Show resolved
Hide resolved
Yeah, I'd considered this and ultimately thought if someone had explicitly defined something in advanced settings, then it would be okay to override things, but I guess it does cause a divergence in the source of truth for both
Yeah, that's fair. I think I went down this rabbit hole once before and it was to do with the way |
Sounds like a good approach to me 👌
It might help in this case too, I used something like this to get the error correctly from an ES propagated one: |
|
@tonyghiani Ready for another look. I've made all of the parameter handling top level, and then pushed the stripping to |
x-pack/solutions/observability/packages/kbn-streams-schema/src/models/ingest/fields/index.ts
Outdated
Show resolved
Hide resolved
...lugins/streams_app/public/components/schema_editor/flyout/advanced_field_mapping_options.tsx
Outdated
Show resolved
Hide resolved
tonyghiani
left a comment
There was a problem hiding this comment.
LGTM, thanks for the changes!
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
cc @Kerry350 |
|
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/13330592124 |
## Summary Closes elastic/streams-program#88 Adds JSON advanced field mapping parameters to the Schema Editor. Main questions here are around the types and data structure. In this PR these are added as an `additionalProperties` property, but we may also want to have all of these parameters top level (like `type` and `format`). This version makes separating concerns easier in the UI and separating "first class" options vs advanced options, I could see pros and cons to both, and also things might be "upgraded" from advanced to first class later on. Also an open question on whether the `MappingProperty` type needs to be explicitly redefined for Zod (ES will obviously reject anything that isn't supported here).   (cherry picked from commit c9dfe9a)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
#211220) # Backport This will backport the following commits from `main` to `8.x`: - [[Streams] Schema Editor advanced field mapping options (#210667)](#210667) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Kerry Gallagher","email":"kerry.gallagher@elastic.co"},"sourceCommit":{"committedDate":"2025-02-14T13:52:18Z","message":"[Streams] Schema Editor advanced field mapping options (#210667)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/streams-program/issues/88\r\n\r\nAdds JSON advanced field mapping parameters to the Schema Editor.\r\n\r\nMain questions here are around the types and data structure. In this PR\r\nthese are added as an `additionalProperties` property, but we may also\r\nwant to have all of these parameters top level (like `type` and\r\n`format`). This version makes separating concerns easier in the UI and\r\nseparating \"first class\" options vs advanced options, I could see pros\r\nand cons to both, and also things might be \"upgraded\" from advanced to\r\nfirst class later on. Also an open question on whether the\r\n`MappingProperty` type needs to be explicitly redefined for Zod (ES will\r\nobviously reject anything that isn't supported here).\r\n\r\n\r\n\r\n\r\n","sha":"c9dfe9aab1ac2146f3c6ec3810ad35f8b753e6c3","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","Feature:Streams","v9.1.0","v8.19.0"],"title":"[Streams] Schema Editor advanced field mapping options","number":210667,"url":"https://github.com/elastic/kibana/pull/210667","mergeCommit":{"message":"[Streams] Schema Editor advanced field mapping options (#210667)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/streams-program/issues/88\r\n\r\nAdds JSON advanced field mapping parameters to the Schema Editor.\r\n\r\nMain questions here are around the types and data structure. In this PR\r\nthese are added as an `additionalProperties` property, but we may also\r\nwant to have all of these parameters top level (like `type` and\r\n`format`). This version makes separating concerns easier in the UI and\r\nseparating \"first class\" options vs advanced options, I could see pros\r\nand cons to both, and also things might be \"upgraded\" from advanced to\r\nfirst class later on. Also an open question on whether the\r\n`MappingProperty` type needs to be explicitly redefined for Zod (ES will\r\nobviously reject anything that isn't supported here).\r\n\r\n\r\n\r\n\r\n","sha":"c9dfe9aab1ac2146f3c6ec3810ad35f8b753e6c3"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210667","number":210667,"mergeCommit":{"message":"[Streams] Schema Editor advanced field mapping options (#210667)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/streams-program/issues/88\r\n\r\nAdds JSON advanced field mapping parameters to the Schema Editor.\r\n\r\nMain questions here are around the types and data structure. In this PR\r\nthese are added as an `additionalProperties` property, but we may also\r\nwant to have all of these parameters top level (like `type` and\r\n`format`). This version makes separating concerns easier in the UI and\r\nseparating \"first class\" options vs advanced options, I could see pros\r\nand cons to both, and also things might be \"upgraded\" from advanced to\r\nfirst class later on. Also an open question on whether the\r\n`MappingProperty` type needs to be explicitly redefined for Zod (ES will\r\nobviously reject anything that isn't supported here).\r\n\r\n\r\n\r\n\r\n","sha":"c9dfe9aab1ac2146f3c6ec3810ad35f8b753e6c3"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Kerry Gallagher <kerry.gallagher@elastic.co>
## Summary Closes elastic/streams-program#88 Adds JSON advanced field mapping parameters to the Schema Editor. Main questions here are around the types and data structure. In this PR these are added as an `additionalProperties` property, but we may also want to have all of these parameters top level (like `type` and `format`). This version makes separating concerns easier in the UI and separating "first class" options vs advanced options, I could see pros and cons to both, and also things might be "upgraded" from advanced to first class later on. Also an open question on whether the `MappingProperty` type needs to be explicitly redefined for Zod (ES will obviously reject anything that isn't supported here).  
Summary
Closes https://github.com/elastic/streams-program/issues/88
Adds JSON advanced field mapping parameters to the Schema Editor.
Main questions here are around the types and data structure. In this PR these are added as an
additionalPropertiesproperty, but we may also want to have all of these parameters top level (liketypeandformat). This version makes separating concerns easier in the UI and separating "first class" options vs advanced options, I could see pros and cons to both, and also things might be "upgraded" from advanced to first class later on. Also an open question on whether theMappingPropertytype needs to be explicitly redefined for Zod (ES will obviously reject anything that isn't supported here).