Skip to content

fix(alerts): route test alert deep links to the cold-load-safe test-results route (#2283)#2296

Open
niccoloalexander wants to merge 2 commits into
elementary-data:masterfrom
niccoloalexander:fix/test-alert-results-deeplink
Open

fix(alerts): route test alert deep links to the cold-load-safe test-results route (#2283)#2296
niccoloalexander wants to merge 2 commits into
elementary-data:masterfrom
niccoloalexander:fix/test-alert-results-deeplink

Conversation

@niccoloalexander

@niccoloalexander niccoloalexander commented Jul 10, 2026

Copy link
Copy Markdown

Fixes the broken cold-load behaviour reported in #2283.

Problem

Test alert deep links (edr monitor --report-url ...) point at #/report/test-runs/<id>. Opening one from a Slack alert is always a cold page load (fresh tab), and on a cold load the detail route's redirect guard fires while report data is still fetching (empty array) and navigates to the parent Test Performance list — so the alert never opens the specific failing test. Pasting the same URL into an already-open report tab works, which is why it only reproduces from alerts. Affects 0.23.1 → current master.

Change

Reroute test alert deep links to #/report/test-results/<id>, which does not hit the guard and cold-loads to the correct test (it also surfaces that test's run history). One-line change in report_link.py.

Caveat (maintainers' call)

This is a link-layer fix for the symptom. The underlying bug is the redirect guard in the report UI; fixing it directly (e.g. gating the redirect useEffect on isFetching, or falling back to embedded report data during fetch) would let test-runs/<id> keep working, and might be your preferred fix. I don't have access to the report UI source (this repo ships the compiled index.html), so this is the fix I can offer from the public repo. Happy to adjust — e.g. also retext the "View test runs" button so its label matches the results destination — if you'd like.

Verified: with this change, edr monitor regenerates the working test-results/<id> link and the alert opens the specific failing test on a cold load.

Summary by CodeRabbit

  • Bug Fixes
    • Updated report-history URL generation to use the correct test-results path for test runs.
    • Improved link behavior for direct page loads of individual test runs to avoid cold-load issues.

…afe)

Test alert deep links point at #/report/test-runs/<id>. On a cold page load
(opening the link from a Slack alert in a fresh tab) the detail route's
redirect guard fires while report data is still fetching (empty array) and
navigates to the parent Test Performance list, so the alert never opens the
specific failing test. Pasting the same URL into an already-open report tab
works, which is why this only reproduces from alerts.

The test-results/<id> route does not hit this guard and cold-loads to the
correct test (it also surfaces the run history), so reroute test alert deep
links there.

This is a link-layer fix for the symptom; the underlying redirect-guard bug
lives in the report UI. Fixing the guard directly (e.g. gating the redirect
useEffect on isFetching, or falling back to embedded report data during fetch)
would let test-runs/<id> keep working — maintainers may prefer that.

Refs elementary-data#2283

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

👋 @niccoloalexander
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c8c36400-c2f7-44db-a9b4-ee07fcb5e6cd

📥 Commits

Reviewing files that changed from the base of the PR and between 0830217 and d78e6c4.

📒 Files selected for processing (1)
  • tests/unit/alerts/test_report_link.py

📝 Walkthrough

Walkthrough

Test run report links now use the test-results route, with comments and unit tests covering cold-load URLs, model links, link labels, and missing inputs.

Changes

Report link path update

Layer / File(s) Summary
Update test result URL path
elementary/monitor/data_monitoring/alerts/integrations/utils/report_link.py
ReportPath.TEST_RUNS now maps to test-results, with a comment documenting cold-load behavior.
Validate report link generation
tests/unit/alerts/test_report_link.py
Tests cover test-results and model-runs URLs, link labels, missing inputs, and tree-node links.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: rerouting test alert deep links to the cold-load-safe test-results route.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
elementary/monitor/data_monitoring/alerts/integrations/utils/report_link.py (1)

17-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider renaming the enum member to match its new value.

The member TEST_RUNS now maps to "test-results", creating a name/value mismatch that could confuse future developers. The comment helps, but renaming to TEST_RESULTS would be self-documenting. This would require updating references in slack.py and any other consumers, so it's best deferred if the rename touches many files.

♻️ Optional rename for consistency
 class ReportPath(Enum):
     # test-runs/<id> cold-loads to the parent list, not the test (see `#2283`)
-    TEST_RUNS = "test-results"
+    TEST_RESULTS = "test-results"
     MODEL_RUNS = "model-runs"

All references to ReportPath.TEST_RUNS (e.g., line 39, and in slack.py) would need to be updated accordingly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@elementary/monitor/data_monitoring/alerts/integrations/utils/report_link.py`
around lines 17 - 19, Rename the ReportPath enum member TEST_RUNS to
TEST_RESULTS to match its "test-results" value, then update every reference to
ReportPath.TEST_RUNS, including usages in slack.py and other consumers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@elementary/monitor/data_monitoring/alerts/integrations/utils/report_link.py`:
- Around line 17-19: Rename the ReportPath enum member TEST_RUNS to TEST_RESULTS
to match its "test-results" value, then update every reference to
ReportPath.TEST_RUNS, including usages in slack.py and other consumers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3b266e64-8676-4c3c-b3f6-59777f1486b5

📥 Commits

Reviewing files that changed from the base of the PR and between 594b89d and 0830217.

📒 Files selected for processing (1)
  • elementary/monitor/data_monitoring/alerts/integrations/utils/report_link.py

Assert test alert deep links resolve to /report/test-results/<id>/ (the
cold-load-safe route, elementary-data#2283) and never /report/test-runs/, that the button
label is unchanged, that model-run links are untouched, and the None cases.

Refs elementary-data#2283

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@niccoloalexander

Copy link
Copy Markdown
Author

Added tests in tests/unit/alerts/test_report_link.py covering the link builders: test alert deep links now resolve to /report/test-results/<id>/ (and never /report/test-runs/), the button label is unchanged, model-run links are untouched, and the None cases.

No docs changes: this is a bug fix to the destination of an existing deep link (not a new user-facing feature or config), and the docs don't reference the report route paths. Happy to add a note somewhere if you'd prefer.

@niccoloalexander

Copy link
Copy Markdown
Author

Thanks @coderabbitai. On the TEST_RUNSTEST_RESULTS rename nitpick — I've left the member name as-is on purpose:

This is an interim reroute. The intended end-state is fixing the report-UI redirect guard (#2283), after which TEST_RUNS should map back to "test-runs". Keeping the member name (plus the inline comment) signals "this is the test-runs link, temporarily pointed at the cold-load-safe route" rather than a permanent semantic change, and keeps the diff to one line instead of rippling into slack.py and the get_test_runs_link / get_model_test_runs_link helpers.

Happy to do the rename if a maintainer would rather treat this as the permanent behaviour.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@niccoloalexander, that makes sense — thanks for the context. Keeping TEST_RUNS as the interim name (with the inline comment) is a reasonable tradeoff to avoid rippling changes into slack.py and the helper functions while #2283 is pending. I won't push for the rename here.

(=^・ω・^=) ~ noted with a nod


✏️ Learnings added
Learnt from: niccoloalexander
URL: https://github.com/elementary-data/elementary/pull/2296

Timestamp: 2026-07-10T14:30:40.886Z
Learning: In elementary/monitor/data_monitoring/alerts/integrations/utils/report_link.py, the `ReportPath.TEST_RUNS` enum member intentionally has its value set to `"test-results"` (not `"test-runs"`) as an interim fix for cold-load-safe test alert deep links. This is temporary until the report-UI redirect guard issue (elementary-data/elementary#2283) is fixed, after which `TEST_RUNS` should map back to `"test-runs"`. The member name is deliberately kept unchanged to avoid rippling changes into slack.py and the `get_test_runs_link` / `get_model_test_runs_link` helpers, so don't flag this name/value mismatch as an issue until `#2283` is resolved.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

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