-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Alerting] Updating Webhook with removed headers doesn't work as expected #71995
Comments
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
I've investigated this issue and it seems fixing this is trickier than you'd expect. The reason this happens is that Saved Objects are updated using partial updates and so, removing a field requires explicitly setting the field with a This is straight forward enough with a field you want to remove, but in this case - it's a sub field. Specifically, we have a dictionary on the Looking into how we're supposed to do a full update, @joshdover suggested doing the following:
This would essentially create a new object, but the It turns out that for security reason we don't allow this: Lines 60 to 67 in 719c292
My suggestion would be to do the following:
kibana/x-pack/plugins/encrypted_saved_objects/server/crypto/encrypted_saved_objects_service.ts Lines 26 to 37 in 719c292
But obviously we'd need @elastic/kibana-security and @elastic/kibana-platform to weigh in before we make such a change. :) |
I wonder if we could instead address this by solving #50256. I need to give this some more thought (so I'm sorry for the half-baked idea), but could we instead update the ESO client's Since partial-updates are problematic for encrypted saved objects, I think it makes sense to prevent that from happening in the first place. We could try to be smart about this and only use |
Yeah sure, I can take that approach, I assumed you wouldn't want that, but from our perspective that's even better (I think 🤔 ) If that approach works for you then I'll revisit my PR |
Ah that makes me think I'm overlooking something nebulous 😄. Were you thinking I wouldn't want this approach because we'd be forcing full updates for encrypted types even if it wasn't strictly necessary? (also cc @azasypkin, I'd love your input here as well) |
Exactly 👍 |
Sorry, I'm not sure I completely understand what is going here. Would you mind giving a bit more details, maybe with real example? What exactly we pass to I'm not opposed to the idea of using |
@azasypkin basically, this is the case: Say you have a SO with these attributes:
If you use
Your SO ends up as:
If you want to unset
But that doesn't remove the Platform team express that this is by design for the SavedObjects and that if we want to wipe the inner fields then we need to overwrite the whole doc. |
I agree completely, but it doesn't sound like we have another option here, unless @elastic/kibana-platform have another suggestion. |
I made a PR that changes EncryptedSavedObjects so that it uses We'll talk to @elastic/kibana-platform to see about adding this to |
I'm quite happy to see an overwriting update capability for SO's to solve our endemic problem of having to But also wondering if changing the |
It's my understanding (based on how we implemented |
That's an interesting thought @pmuellr but as we're not less confident in our ability to migrate ESOs (and have reverted our usage of it until 7.10) I don't think that'll actually give us an incremental step in the right direction and as we also want to address #50256 it might be best to address them both in the same manner. |
I wanted to summarize where we're at on this, as it turned out to be far more complicated than originally thought and now that we've decided that it is too large a change to fit into 7.9, I think we can slow down on the implementation and make sure we're going in the right direction. In order to address this issue, we need to ensure that whenever we update an Alert's SavedObejct, we replace the whole document instead of updating the existing one. This is to avoid Elasticsearch's default behaviour of merging documents, making it impossible to delete keys in objects (not without explicitly nulling them out, which is unmaintainable in the long run). We could do this by changing every One problem this change has revealed, is that the underlying SavedObjects client does not support version on the Changing how we update documents revealed a bigger issue - which is what has made this change set far larger. Now that we've decided to hold off on merging this work until 7.9.1 / 7.10 (it's too close to release to fix this in 7.9) we could ask Platform/Security to address the changes in their own code and we would focus on the changes in Alerting, but I'm not sure the resulting context switching will actually speed things up. My feelings are that it would be more a question of ownership than capacity, but I can't speak for Platform / Security on this. |
I've started to think of these two types of update as I think they are both useful. Ideally, the current SO/ESO Could we leave SO/ESO As a separate issue, I wonder if there would be some TS pixie dust we could sprinkle over ESOs to help prevent AAD issues, for cases of partial updates. Assuming we get an "overwrite" capability and still have a partial update "update" capability for ESO's, I think I'd be very leery of using a partial update with an ESO without some typing help, deferring to just always using an "overwrite" instead. |
Sadly, this has unearthed a deeper hole and to side step digging down the rabbit hole, I've spoke to @legrego and @azasypkin and we've decided Security will take ownership of changing the ESO client instead of us as part of this PR. Instead, we'll make changes in Alerting to use
Sadly, that's not doable without changing the SavedObjectClient itself as ESO is hidden by the SO client with which we interact directly. |
That would definitely be out of scope for this issue :) |
After syncing with @pmuellr regarding this work and the work he's been doing around the Alert Status issue, we've realised that the approach taken my initial PR is going to clash with his. After reviewing Patrick's work (over here #75553) I've decided to hold off on this issue until his PR is merged. This does mean that much of the work done in my initial PR (#73688) will no longer be mergable, but it will allow us to build on top of his work to address this by providing two methods for updating an Alert - a partial one and a full one (which uses I'll mark this as blocked for the time being |
Currently, deleting existing header in the Webhook connector doesn't work. At the same time you can update Webhook headers with the new header.
Steps to reproduce:
Expected behavior:
Deleting Webhook headers should works.
Seems like some there is some caching issue on the server side for savedObjectClient.find
The text was updated successfully, but these errors were encountered: