-
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
[ResponseOps] Hyperlinks in Slack messages are broken when there is "_" or "*" in the URL #170067
Conversation
Pinging @elastic/response-ops (Team:ResponseOps) |
@@ -144,13 +144,6 @@ function escapeSlack(value: unknown): string { | |||
if (value == null) return ''; | |||
|
|||
const valueString = `${value}`; | |||
// if the value contains * or _, escape the whole thing with back tics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like it's too broad of a change. The reason we escape variable content containing *
or _
is to prevent Slack from treating these as bold or italic. By removing this escaping completely, variables with those characters will end up causing probably unwanted style changes in the message.
I wonder if we can be a little more specific. Could we check if the value is a URL (see if URL.parse() or whatever doesn't throw an error)? If it IS a URL, do something different, otherwise do the existing thing (wrap the whole thing in back-tics).
As an additional thought, I wonder if we should uri encode the URL while we're at it? This would fix some additional issues, but is somewhat magical, so my brain says no ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in this commit 1c76b5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Tested by setting server.publicBaseUrl: http://local_host:5601/
, and then adding a Slack action that renders {{kibanaBaseUrl}}
- no back tics!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
Resolves #165673
Summary
escapeSlack
function in the mustasche_renderer breakes the hyperlinks by wrapping the URL with backticks.So the below markdown template does not work.
<{{context.alertDetailsUrl}}|View alert details>
This PR removes the code that adds backticks.
With this change action variables with text wrapped in asterisks *text* will render as text or wrapped in underscores _text_ will render as text .
Checklist
To verify