Skip to content

Fix/<a> having dashboard by identifier as link - #73

Merged
imenattatra merged 3 commits into
metr-mainfrom
fix/a-having-dashboard-by-identifier-as-link
Jul 6, 2026
Merged

Fix/<a> having dashboard by identifier as link#73
imenattatra merged 3 commits into
metr-mainfrom
fix/a-having-dashboard-by-identifier-as-link

Conversation

@imenattatra

@imenattatra imenattatra commented Jul 6, 2026

Copy link
Copy Markdown

Closes https://github.com/metr-systems/backlog/issues/4919

AI Disclaimer: Yes claude , assisted in finding the fix and its implementation

Summary

Clicking a dashboard link that uses by_url_identifier (e.g. from inside a visualization) showed an error page, and only worked after a manual refresh. This PR fixes it so the dashboard opens directly, with no refresh.

Code Strategy

The by_url_identifier redirect only existed server-side. When such a link is clicked inside the app, Redash's global navigation handler routes it client-side, so the request never reaches the server and the redirect never runs — hence the error (a refresh worked because it's a real server request).

Rather than force a full page reload, we resolve it in-app:

  • New JSON endpoint GET /api/dashboards/by_url_identifier/<url_identifier> to fetch the dashboard by its identifier (org-scoped, same access checks as the id/slug path).
  • Dashboard.get can call it via urlIdentifier.
  • A client route renders DashboardPage and rewrites the URL to the canonical {id}-{slug}.

QA

How did you test it? Keep your future self in mind to help debug things later.

  • Manually (on staging)
  • Unit tests

Notes:

This is a fix and will be deployed today

Add GET /api/dashboards/by_url_identifier/<url_identifier>, served by the
existing DashboardResource, so a dashboard can be fetched by its Metr
url_identifier (the current JSON endpoint only resolves by id/slug).

Access stays fully org-scoped, same as the id/slug path:
- the route is registered via add_org_resource, so it lives under the org
  slug and current_org is resolved from it;
- get_by_url_identifier_and_org_or_404 filters by org_id (404 otherwise);
- require_dashboard_group_access enforces per-dashboard access.

Update add_allowed_widgets_info to accept the new route's kwarg and, when
the lookup wasn't by numeric id, resolve the allowed-widgets query id from
the response — id/slug paths are unchanged.

Add tests for the happy path and unknown identifier (404).
Dashboard.get accepts a urlIdentifier and calls the new
by_url_identifier endpoint; id/slug lookups unchanged.
In-app clicks on <a> links to /dashboards/by_url_identifier/... were
intercepted by Redash's global client-side navigation handler, so the
request never reached the server-side redirect. With no matching client
route, the greedy dashboard route tried to load an invalid id and showed
an error (it only worked after a refresh, which hit the server 302).

Register a client route that renders DashboardPage resolved by
url_identifier, then rewrites the URL to the canonical {id}-{slug}.

Fixes metr-systems/backlog#4919
@imenattatra
imenattatra requested review from a team and helenalebreton July 6, 2026 14:35
@imenattatra imenattatra changed the title Fix/a having dashboard by identifier as link Fix/<a> having dashboard by identifier as link Jul 6, 2026
@imenattatra
imenattatra merged commit 0edbc91 into metr-main Jul 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant