Skip to content

Conversation

@abhishekhugetech
Copy link
Contributor

@abhishekhugetech abhishekhugetech commented Dec 29, 2025

📄 Summary

Updated the link generation logic for test alert notifications. Previously, test alerts for rules currently being created resulted in broken links due to missing Alert IDs (since the alert does not yet exist in the DB).

Key Changes:

Modified the notification link to include a specific query parameter (isTestAlert indicating a "test" context) for all test alerts.

This would allow the Frontend to route the user to a specific preview/test page using the query parameter, bypassing the requirement for a pre-existing Alert ID.


✅ Changes

  • Feature: Brief description
  • Bug fix: Brief description

🏷️ Required: Add Relevant Labels

⚠️ Manually add appropriate labels in the PR sidebar
Please select one or more labels (as applicable):

ex:

  • frontend
  • backend
  • devops
  • bug
  • enhancement
  • ui
  • test

👥 Reviewers

Tag the relevant teams for review:

  • frontend / backend / devops

🧪 How to Test

  1. ...
  2. ...
  3. ...

🔍 Related Issues

Closes #


📸 Screenshots / Screen Recording (if applicable / mandatory for UI related changes)


📋 Checklist

  • Dev Review
  • Test cases added (Unit/ Integration / E2E)
  • Manually tested the changes

👀 Notes for Reviewers


Note

Improves alert link generation, especially for test alerts.

  • In rules/manager.go, set labels.TestAlertLabel to "true" for test notifications so downstream templates can detect test alerts
  • Add TestAlertLabel to utils/labels/labels.go
  • Update alertmanagertypes/template.go:
    • Register custom urlescape template func and use it for ruleId
    • Refactor __ruleIdPath to: use ruleId if present/non-empty, append &isTestAlert=true when testalert=true, otherwise omit the edit path
  • Add comprehensive tests in alertmanagertypes/template_test.go covering single/multiple alerts, matching/mismatching/blank ruleId, testalert handling, and URL-escaping

Written by Cursor Bugbot for commit cd59742. This will update automatically on new commits. Configure here.

@github-actions github-actions bot added the bug Something isn't working label Dec 29, 2025
@abhishekhugetech abhishekhugetech marked this pull request as ready for review December 30, 2025 11:33
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

funcs := tmpltext.FuncMap{
"urlescape": func(value string) string {
return url.PathEscape(value)
},
Copy link

Choose a reason for hiding this comment

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

PathEscape used instead of QueryEscape for query parameter

The urlescape function uses url.PathEscape instead of url.QueryEscape for encoding the ruleId query parameter value. PathEscape doesn't encode characters like &, =, and / that have special meaning in query strings. If a ruleId contains these characters (e.g., foo&bar), the generated URL would be malformed (?ruleId=foo&bar instead of ?ruleId=foo%26bar), causing incorrect URL parsing. Since the UUID regex validation was also removed, arbitrary ruleId values are now accepted, increasing the likelihood of this issue occurring.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant