Skip to content

Fix routing preview visualization#1531

Merged
VikaCep merged 1 commit into
mainfrom
fix/alert-routing-preview
Jan 8, 2026
Merged

Fix routing preview visualization#1531
VikaCep merged 1 commit into
mainfrom
fix/alert-routing-preview

Conversation

@VikaCep

@VikaCep VikaCep commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

Problem

The alert routing preview feature was failing with the following error:

Plugin failed to load
Error: Warning: Middleware for RTK-Query API at reducerPath "notifications.alerting.grafana.app/v0alpha1" has not been added to the store.
You must add the middleware for RTK-Query to function correctly!

or

Plugin failed to load
Details
TypeError: g.current.isRequestSubscribed is not a function

    at ZE (https://plugins-cdn.grafana.net/grafana-synthetic-monitoring-app/1.43.0/public/plugins/grafana-synthetic-monitoring-app/962.93e179f421b17fdeb963.js:1044:17700)
    at div
    at div
    at Cw (https://plugins-cdn.grafana.net/grafana-synthetic-monitoring-app/1.43.0/public/plugins/grafana-synthetic-monitoring-app/962.93e179f421b17fdeb963.js:1044:37516)

depending whether it's run with Graft or without it.

This error started appearing after the 12.3.0 Grafana release. The root cause is that the useMatchInstancesToRouteTrees hook from @grafana/alerting uses RTK-Query internally, which requires middleware to be registered in the Redux store. Plugins don't have access to configure Grafana's main Redux store, and it breaks when trying to run it.

Solution

Created a custom implementation of useMatchInstancesToRouteTrees that bypasses the RTK-Query middleware requirement while maintaining full compatibility with the original hook.

The implementation:

  • Manually fetches routing tree data using getBackendSrv()
  • Uses the standalone matchInstancesToRouteTrees function from @grafana/alerting to process the data
  • Returns the same interface as the original hook, making it a drop-in replacement

Note: This should be a temporary solution as the grafana/alerting hook should not break because of this. The alerting team has been notified of the problem.

Before:
image

After:

image

@VikaCep VikaCep self-assigned this Jan 7, 2026
@VikaCep VikaCep requested a review from a team as a code owner January 7, 2026 21:21
@VikaCep VikaCep requested review from ckbedwell and w1kman and removed request for a team January 7, 2026 21:21
@github-actions github-actions Bot added the fix A fix applied to the application. label Jan 7, 2026
@github-actions

github-actions Bot commented Jan 7, 2026

Copy link
Copy Markdown

Script size changes

Name +/- Main This PR Outcome
[168.js] New file - 1,640.30 kB
[448.js] New file - 977.35 kB
[datasource/module.js] = 24.53 kB 24.53 kB
[692.js] = 20.57 kB 20.57 kB
[663.js] = 5.84 kB 5.84 kB
[module.js] -1.40% 4.92 kB 4.86 kB
[767.js] Deleted file 1,717.17 kB -
[962.js] Deleted file 976.83 kB -

Totals

Name +/- Main This PR Outcome
[Scripts] -2.78% 2,749.87 kB 2,673.44 kB
[Non-script Assets] = 2,668.90 kB 2,668.90 kB
[All] -1.41% 5,418.77 kB 5,342.34 kB

Generated by 🚫 dangerJS against 81cf5b5

@VikaCep VikaCep force-pushed the fix/alert-routing-preview branch from bb2c699 to 81cf5b5 Compare January 7, 2026 21:41

@w1kman w1kman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 🥳

@VikaCep

VikaCep commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

Holding off on merging because I first want to try upgrading the package/alerting version, as recommended by the alerting team (#1532)

@VikaCep

VikaCep commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

The hook's fix is in grafana/alerting@12.4.0-20823894528 (as per grafana/grafana#116016) but it fails to publish to npm so we can't consume it. Merging this fix until we can upgrade the package's version.

@VikaCep VikaCep merged commit 50b7825 into main Jan 8, 2026
32 checks passed
@VikaCep VikaCep deleted the fix/alert-routing-preview branch January 8, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix applied to the application.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants