We upgraded some environments to 2.2 but it seems it boke our custom webhook. It’s a very simple one, just a server:port with an extension, nothing complex. We have some environments still at 1.3 and the exact same setup works. If I try a test message I get an error
“[status_exception] statusText is null or empty”
I will say I have a VM running the the opensearch-2.2.0/opensearch-tar-install.sh and running a simple Python webserver with Flask and it works so not something broken with the version. It’s just a strange error and the message is not much help.
TIA
faabsen
January 25, 2023, 10:33am
2
We have the same error: however, it looks like the alarm is being send correctly.
Seems like a bug within the new Notification Plugin of OpenSearch:
opened 09:39PM - 01 Feb 23 UTC
bug
**What is the bug?**
The status is retrieved from the [response of sendMessage]… (https://github.com/opensearch-project/notifications/blob/b5379b6e7d1211b9a9e6f3cc25633fe7f9e0d569/notifications/notifications/src/main/kotlin/org/opensearch/notifications/send/SendMessageActionHelper.kt#L579). In this case it'll be calling [the execute of DestinationHttpClient](https://github.com/opensearch-project/notifications/blob/b5379b6e7d1211b9a9e6f3cc25633fe7f9e0d569/notifications/core/src/main/kotlin/org/opensearch/notifications/core/client/DestinationHttpClient.kt#L93) to send the message. The [responseString](https://github.com/opensearch-project/notifications/blob/b5379b6e7d1211b9a9e6f3cc25633fe7f9e0d569/notifications/core/src/main/kotlin/org/opensearch/notifications/core/client/DestinationHttpClient.kt#L100) here is what becomes the `statusText`.
The response string is [derived from the entity of the response](https://github.com/opensearch-project/notifications/blob/b5379b6e7d1211b9a9e6f3cc25633fe7f9e0d569/notifications/core/src/main/kotlin/org/opensearch/notifications/core/client/DestinationHttpClient.kt#L143). An HTTP entity in the response can be empty (`""`) or there can be no entity (`null`). The `null` case is being covered by replacing it with the `{}` string but it looks like the empty case wasn't being covered differently and was just returning an empty string. This is not a valid argument for the `statusText` param of what gets passed to `DeliveryStatus`, resulting in an `IllegalArgumentException`.
**What is the expected behavior?**
I think we should just check for `isNullOrEmpty` when getting the response string and make both represented as `{}`. I only see that method being used to return to the contents of what populates `DestinationMessageResponse`. If we want to distinguish between `null` and `empty` and not use `{}` for both for whatever reason, then I think `DeliveryStatus` should support empty `statusText` if that's derived from the HTTPEntity.
From an HTTP perspective, an empty entity is different from no entity. However, since we're talking about what ultimately becomes the string representation of the `statusText`, I'd prefer the former approach between the two above as it's simpler.
Yes, it has been fixed since version 2.5