fix(alerts): raise ValidationError for deprecated sessions dataset#119455
Draft
billyvg wants to merge 1 commit into
Draft
fix(alerts): raise ValidationError for deprecated sessions dataset#119455billyvg wants to merge 1 commit into
billyvg wants to merge 1 commit into
Conversation
Dataset.Sessions is deprecated but was still accepted by validate_dataset, causing an unhandled KeyError in _validate_query when looking up query_datasets_to_type. Now returns a clear deprecation error message pointing users to the metrics dataset for crash rate alerts instead. Fixes SENTRY-5PEF Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an unhandled
KeyError(SENTRY-5PEF) in the alert rule creation endpoint that surfaces as a 500 error for users attempting to create crash rate alerts with the legacysessionsdataset.Root cause:
validate_datasetinSnubaQueryValidatoraccepts any validDatasetenum value — including the deprecatedDataset.Sessions— and passes it along. In_validate_query, line 321 does a dict lookup:Dataset.Sessionsis not inquery_datasets_to_type(which maps to alert types), so this raises an unhandledKeyErrorinstead of a user-friendly validation error.Fix: Add an explicit check for
Dataset.Sessionsinvalidate_datasetthat raises a clearValidationErrordirecting users to themetricsdataset for crash rate alerts. This is the correct dataset per the currentQUERY_TYPE_VALID_DATASETSmapping (onlyDataset.Metricsis valid forCRASH_RATEtype).Evidence from Sentry:
Session: https://claude.ai/code/session_01J4LcBkJp5FmPYfxmFcq6ZV
Generated by Claude Code