-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Export hooks are not called when exporting referenced saved objects #100043
Comments
Pinging @elastic/kibana-core (Team:Core) |
Took a quick look at this, and AFAICT it must have been a case we didn't consider in the initial implementation. The SO exporter tests check that the transforms are applied to a SO type, but not that they are applied to referenced objects. |
I can confirm we just did not think of that in the initial implementation. I need to take a closer look, I suspect it may be a little tricky to implement due to the fact that the export hooks can return objects with their own references, so we would need to recurse on the object tree after each call to the export hooks. |
To cross-link, this feature may have some complex interactions with the capability to filter objects out of the export (#99680), see #99680 (comment). I do think that we'll want to implement a solution for current issue anyway, and think about the interactions when trying to address #99680, as this one is more of a bug, and #99680 more of an enhancement. |
So, after #100043 (comment), I digged a bit deeper. We currently perform the operation in two steps
To properly invoke export hooks on the whole tree, we will need to
|
@ymao1 opened a PR to address this: #100769 Had a question though: atm, the PR is fixing the issue by invoking the export hooks on all the referenced objects E.g objA has a reference to objB => the export hooks will be execute for both objA and objB however, I'm still not invoking export hooks on objects returned by the export hooks. E.g if typeA has an export hook that will include some typeB docs, and typeB has an export hook registered, it will not invoke the export hooks for the typeB docs returned from the typeA hook. Is that alright, or do you also need this? (this is only impacting if you're using the export hook to add additional objects to the export list, not if you're just mutating the objects properties before export) |
@pgayvallet Thanks for looking into this! For our current use case, what you've done is exactly what we need: having the export hooks for both objA and objB executed if objA contains a reference to objB. I tried out your PR with rules & connectors and it is working as expected! I am trying to think of a case where we might, in the future, need to add additional objects to the export but am coming up empty (and it seems like it would be a strange user experience to export an object and then have it show up with new references when imported elsewhere?). That said, that doesn't mean there'll never be a use case for it, so maybe it would be good to open a separate issue for that and see if there are any requests for it? |
I have two saved object types
alerts
andactions
that implement theonExport
hook to perform some simple transformations before export. Thealerts
SO can reference theactions
SO. When exportingactions
on their own, theonExport
hook is called correctly. When exportingalerts
with referencedactions
, thealerts
onExport
hook is called bu theactions
onExport
hook is not called and theactions
are not correctly transformed before export.The text was updated successfully, but these errors were encountered: