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: Fix incorrect decoding for alert rules with % characters #76148
Conversation
Tests are currently failing because they rely pretty heavily on mocked location data passed in to the ruler viewer – I'll need to find a way around that to unblock this PR. |
…ecode-alert-rule-name
/deploy-to-hg |
|
|
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 on my local ✅
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.
- are we confident this patch to
history
won't cause unintended behaviour elsewhere in the app? - if so, can we please create an issue to upgrade
react-router
+history
, including the context from https://github.com/grafana/grafana/pull/76148/files#diff-d39aa8bb5f5c32177ba0cef60b1277b58288013d5d2ac2daaa68930771e4c350R251-R256, and also reminding us to remove the patch. i don't know where that issue should live - tbh it probably ends up on frontend platform's board 😬
// It was probably fixed in React-Router v6 | ||
type PathWithOptionalID = { id?: string }; | ||
export function getRuleIdFromPathname(params: PathWithOptionalID): string | undefined { | ||
const { pathname = '' } = locationService.getLocation(); |
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.
Now that we're patching the router, do we still need this workaround? Can we go back to using useParams()
?
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.
I need to verify. IIRC react-router-dom
has the same bug. In this PR we only patch the history
package so it doesn't break outgoing links, but it shouldn't affect parsing path params
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.
I created this issue @ashharrison90 , should I assign to the Grafana Frontend platform project? |
@soniaAguilarPeiron sure 👍 |
@ashharrison90 This patch does the same as this fix , that has been merged to main. So, we believe it should not break anything. We tested locally and on the ephemeral instance. We cannot be 100% confident about not breaking anything, but we believe it should not. |
/deploy-to-hg |
|
|
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!
What is this feature?
This PR fixes a crash in the front-end when trying to view the details for an alert rule that has a "%" character encoded in the alert rule name.
This can be traced to a bug in react-router (remix-run/history#505).
the rule editor was also affected, it didn't crash but also did not properly decode the rule identifier.
Special notes for your reviewer:
Some additional manual testing would be appreciated since I failed to successfully write a test to mock
window.location