Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

fix(alert): normalize dataset aliases in metric alert commands - #1356

Merged
jared-outpost[bot] merged 2 commits into
mainfrom
seer/fix/alert-dataset-normalization
Aug 4, 2026
Merged

jared-outpost[bot] merged 2 commits into
mainfrom
seer/fix/alert-dataset-normalization

Conversation

@sentry

@sentry sentry Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

sentry alert metrics create and sentry alert metrics edit reject 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 in METRIC_DATASET_VALUES, so they fail validateMetricDataset with a ValidationError, even though they clearly map to a valid canonical value.

(The already-canonical values errors, transactions, sessions, events, spans, metrics pass validation today — they are not what this PR fixes.)

This fix:

  • Adds a METRIC_DATASET_ALIASES map and normalizeMetricDataset helper in packages/cli/src/commands/alert/mutation-utils.ts, resolving safe aliases to their canonical metric-alert value (error → errors, error-events → errors, transaction-like → transactions, …).
  • Only aliases that resolve to an already-valid metric-alert dataset are included. Names that denote a distinct dataset in the metric-alert path (tracemetrics, metricsenhanced, eap, events_analytics_platform) are deliberately not aliased — rewriting them onto metrics/spans would silently send the wrong dataset with no validation error. Note the metric-alert canonical names are the inverse of the dashboard/explore subsystem, where tracemetrics is canonical and metrics is the alias.
  • validateMetricDataset normalizes before checking, and create.ts/edit.ts use the normalized value for both validation and the API payload.
  • Adds normalizeMetricDataset test coverage (alias resolution, case-insensitivity, passthrough of unknown/distinct datasets) and updates the --dataset help text to advertise the synonyms.

Fixes CLI-JG

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@github-actions

github-actions Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-04 13:52 UTC

@BYK
BYK marked this pull request as ready for review August 4, 2026 11:16
@BYK BYK added the jared Trigger the Jared agent to work on stuff label Aug 4, 2026

@jared-outpost jared-outpost Bot 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.

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.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

@BYK

BYK commented Aug 4, 2026

Copy link
Copy Markdown
Member

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.
@jared-outpost
jared-outpost Bot enabled auto-merge (squash) August 4, 2026 13:44
@jared-outpost
jared-outpost Bot merged commit 1c6fee0 into main Aug 4, 2026
31 checks passed
@jared-outpost
jared-outpost Bot deleted the seer/fix/alert-dataset-normalization branch August 4, 2026 13:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

jared Trigger the Jared agent to work on stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant