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

Set message when building LegacyCustomWebhookMessage #670

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

partlov
Copy link
Contributor

@partlov partlov commented Nov 9, 2022

Signed-off-by: Petar Partlov [email protected]

Issue #, if available:

Description of changes:
While testing legacy destinations for custom webhooks I discovered issue which is 100% reproducible. Scope should not be huge as this can influence only users with some issue during migration of old legacy notification system to new which uses notification plugin.

Issue is that one of required field (message) was not set during building instance of LegacyCustomWebhookMessage object.

CheckList:
[ ] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@partlov partlov marked this pull request as ready for review November 10, 2022 11:30
@partlov partlov requested a review from a team November 10, 2022 11:30
@@ -260,7 +260,7 @@ data class Destination(
}
DestinationType.CUSTOM_WEBHOOK -> {
destinationMessage = LegacyCustomWebhookMessage.Builder(name)
.withUrl(getLegacyCustomWebhookMessageURL(customWebhook))
.withUrl(getLegacyCustomWebhookMessageURL(customWebhook, compiledMessage))
.withHeaderParams(customWebhook?.headerParams)
.withMessage(compiledMessage).build()
Copy link
Contributor

Choose a reason for hiding this comment

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

The message is passed in here. It's not required in getLegacyCustomWebhookMessageURL since that method is only combining the individual URL parameters to a String to pass to withUrl.

Copy link
Contributor

@qreshi qreshi Nov 10, 2022

Choose a reason for hiding this comment

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

Ah, I see what you're saying. We're not setting message in the builder and it's throwing an IllegalArgumentException when we call build() in getLegacyCustomWebhookMessageURL()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that is correct. It is true that it is not required for actual construction of URI, but unfortunately it is required field of LegacyCustomWebhookMessage and it always throws IllegalArgumentException("Message content is missing"). I went with this solution as it is simple and this legacy destination is only used in limited number of cases (and it will probably be removed in some of future releases).

It would probably be best to completely separate URI construction code of constructing LegacyCustomWebhookMessage object itself, but as message is available here I went with this easy fix.

@lezzago lezzago merged commit 9d9f588 into opensearch-project:main Dec 1, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Dec 1, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Dec 1, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Dec 1, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Dec 1, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Dec 1, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Dec 1, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)
lezzago pushed a commit that referenced this pull request Dec 20, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)

Co-authored-by: Petar Partlov <[email protected]>
lezzago pushed a commit that referenced this pull request Dec 20, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)

Co-authored-by: Petar Partlov <[email protected]>
lezzago pushed a commit that referenced this pull request Dec 20, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)

Co-authored-by: Petar Partlov <[email protected]>
lezzago pushed a commit that referenced this pull request Dec 20, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)

Co-authored-by: Petar Partlov <[email protected]>
lezzago pushed a commit that referenced this pull request Dec 20, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)

Co-authored-by: Petar Partlov <[email protected]>
lezzago pushed a commit that referenced this pull request Dec 20, 2022
Signed-off-by: Petar Partlov <[email protected]>

Signed-off-by: Petar Partlov <[email protected]>
(cherry picked from commit 9d9f588)

Co-authored-by: Petar Partlov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants