Compare commits

..

1 Commits

Author SHA1 Message Date
Nikhil Soni
cbb30cb60e fix: handle legacy alert type values on patch 2026-05-07 13:51:53 +05:30
3 changed files with 10 additions and 5 deletions

View File

@@ -327,11 +327,6 @@ function App(): JSX.Element {
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
beforeSend(event) {
// Drop the event if its level is 'warning' or 'info'
if (event.level === 'warning' || event.level === 'info') {
return null;
}
const sessionReplayUrl = posthog.get_session_replay_url?.({
withTimestamp: true,
});

View File

@@ -952,6 +952,7 @@ func (m *Manager) PatchRule(ctx context.Context, ruleStr string, id valuer.UUID)
m.logger.ErrorContext(ctx, "failed to unmarshal rule from db", slog.String("rule.id", id.StringValue()), errors.Attr(err))
return nil, err
}
storedRule.NormalizeAlertType()
if err := json.Unmarshal([]byte(ruleStr), &storedRule); err != nil {
m.logger.ErrorContext(ctx, "failed to unmarshal patched rule with given id", slog.String("rule.id", id.StringValue()), errors.Attr(err))

View File

@@ -36,6 +36,15 @@ func (AlertType) Enum() []any {
}
}
// NormalizeAlertType corrects known legacy alert type values that were stored
// before strict validation was introduced. The corrected value is persisted on
// the next write, so the DB self-heals without a migration.
func (r *PostableRule) NormalizeAlertType() {
if r.AlertType == "LOG_BASED_ALERT" {
r.AlertType = AlertTypeLogs
}
}
const (
DefaultSchemaVersion = "v1"
SchemaVersionV2Alpha1 = "v2alpha1"