Repository navigation
fix(alert): normalize dataset aliases in metric alert commands - #1356
Conversation
|
There was a problem hiding this comment.
The normalization approach is sound and the change is safe — tests pass, and mapping dashboard-terminology datasets (error-events, transaction-like, tracemetrics) onto the metric-alert canonical forms (errors, transactions, metrics) mirrors what normalizeDataset does for dashboards, just in the opposite direction (metric alerts use errors/metrics as canonical, dashboards use error-events/tracemetrics). A couple of things to address:
1. No test coverage for the new aliasing (the actual point of this PR).
normalizeMetricDataset and its METRIC_DATASET_ALIASES map are the behavioral change here, but mutation-utils.test.ts only exercises validateMetricDataset with already-canonical values. Please add cases in packages/cli/test/commands/alert/mutation-utils.test.ts asserting the mappings resolve, e.g. error-events → errors, transaction-like → transactions, tracemetrics/metricsenhanced → metrics, eap/events_analytics_platform → spans, plus case-insensitivity (ERROR-EVENTS) and passthrough of unknown values.
2. PR description has the root cause backwards.
The body says these commands "would fail with a ValidationError when users provided common dataset aliases like errors, transactions, or metrics" — but those three are already in METRIC_DATASET_VALUES and pass validation today; they're not what this PR fixes. The values this PR actually rescues are the dashboard/EAP synonyms (error-events, transaction-like, tracemetrics, eap, ...). The body also calls error-events/transaction-like/tracemetrics the "canonical API forms," which is inverted for metric alerts — the code normalizes away from those. Worth fixing so the intent is clear to reviewers and future readers.
3. (minor) --dataset help text doesn't advertise the new synonyms.
The flag brief in create.ts/edit.ts still reads Dataset (errors, transactions, sessions, events, spans, metrics). The dashboard widget add/edit briefs list their synonyms (error-events/errors, ...). Consider matching that so users discover the aliases.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f0f6fb3. Configure here.
|
Jared, address all the issues and get this merged |
Remove tracemetrics/metricsenhanced/eap/events_analytics_platform from METRIC_DATASET_ALIASES — these denote distinct datasets in the metric alert path, so rewriting them onto metrics/spans silently sends the wrong dataset with no validation error (flagged by Cursor Bugbot). Keep only the safe aliases that resolve to an already-valid value: singular forms and dashboard error/transaction terminology. Add normalizeMetricDataset test coverage and advertise the synonyms in the --dataset help text.

sentry alert metrics createandsentry alert metrics editreject dataset values that users reasonably expect to work — the singular forms (error,transaction, …) and the dashboard-terminology names for the error/transaction datasets (error-events,transaction-like). Those aren't inMETRIC_DATASET_VALUES, so they failvalidateMetricDatasetwith aValidationError, even though they clearly map to a valid canonical value.(The already-canonical values
errors,transactions,sessions,events,spans,metricspass validation today — they are not what this PR fixes.)This fix:
METRIC_DATASET_ALIASESmap andnormalizeMetricDatasethelper inpackages/cli/src/commands/alert/mutation-utils.ts, resolving safe aliases to their canonical metric-alert value (error→errors,error-events→errors,transaction-like→transactions, …).tracemetrics,metricsenhanced,eap,events_analytics_platform) are deliberately not aliased — rewriting them ontometrics/spanswould silently send the wrong dataset with no validation error. Note the metric-alert canonical names are the inverse of the dashboard/explore subsystem, wheretracemetricsis canonical andmetricsis the alias.validateMetricDatasetnormalizes before checking, andcreate.ts/edit.tsuse the normalized value for both validation and the API payload.normalizeMetricDatasettest coverage (alias resolution, case-insensitivity, passthrough of unknown/distinct datasets) and updates the--datasethelp text to advertise the synonyms.Fixes CLI-JG
Comment
@sentry <feedback>on this PR to have Autofix iterate on the changes.