Skip to content

feat(notification): read versioned event types while preserving legacy writes - #5546

Merged
chrisgacsal merged 2 commits into
mainfrom
feat/notification-event-type-compatibility
Nov 16, 2026
Merged

chrisgacsal merged 2 commits into
mainfrom
feat/notification-event-type-compatibility

Conversation

@chrisgacsal

@chrisgacsal chrisgacsal commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Teach the Notification adapter to read legacy and versioned Event type names for Rules and Events. During a rolling deployment, writers continue to store the legacy type in the column and JSON envelope so older backends can read new records. V1 and V3 continue to expose the legacy names.

V1/V3 name Versioned storage name
invoice.created v1.billing.invoice.created
invoice.updated v1.billing.invoice.updated
entitlements.balance.threshold v1.entitlement.balance_threshold.triggered
entitlements.reset v1.entitlement.usage_period.reset

Notes for reviewer

V3 equality, one-of, and exclusion filters expand each public name to both stored spellings. Sorting by type uses the public name followed by resource ID before pagination. The mapping applies to stored type columns. Payload contracts and the switch to versioned writes are separate rollout steps.

PostgreSQL race tests passed for the Notification adapter, service, V1 HTTP driver, and V3 handler packages. Tests cover mixed spellings, legacy writes, and one-item pages in both sort directions. Lint passed for the affected packages.

RetriggerView in GreptileConfidence Score: 5/5

This PR appears safe to merge; the previous naming issue is addressed and no new actionable issues remain.

Summary

Rules and Events now read legacy and versioned type names while keeping legacy writes and public names.

  • Rule and Event reads return legacy names for versioned type columns.
  • Rule and Event lists filter and sort mixed type names as one public type.

Reviews (2) · Last reviewed commit: "refactor(notification): keep event type ..." · Reviewed by Greptile

Summary by CodeRabbit

  • Bug Fixes
    • Notification events and rules remain readable when their stored types use versioned aliases, while public responses continue to show legacy type names.
    • Type filters now match either stored spelling, and event and rule lists sort consistently by the legacy type name.
  • Documentation
    • Clarified how legacy and versioned notification type names are handled in reads, filters, and external representations.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Notification adapters now read versioned event type values as legacy public names. Rule and event list operations filter and sort across both stored spellings. Tests cover adapter behavior and V3 endpoint responses.

Changes: Notification type compatibility

Layer / File(s) Summary
Type aliases and mapping
openmeter/notification/adapter/entitymapping.go, openmeter/notification/README.md
The adapter maps four versioned database type names to legacy public names. It adds predicates that match both stored spellings and ordering based on the legacy name. The README documents the aliases and V3 filtering and sorting behavior.
Rule and event list operations
openmeter/notification/adapter/event.go, openmeter/notification/adapter/rule.go
Event and rule lists use the compatible type predicate when a non-empty type filter is supplied. Type ordering uses the legacy name and resource ID as a tie-breaker.
Compatibility validation
openmeter/notification/adapter/event_test.go, openmeter/notification/adapter/rule_test.go, openmeter/notification/service/event_test.go
Adapter tests check reads, filtering, and stored values for versioned names. V3 endpoint tests check public names, filters, sorting, pagination, and rejection of versioned public filters.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant V3API
  participant NotificationAdapter
  participant Database
  V3API->>NotificationAdapter: List events or rules with type filter and sort order
  NotificationAdapter->>Database: Query using compatible type predicate and ordering
  Database-->>NotificationAdapter: Return entities with stored type names
  NotificationAdapter-->>V3API: Return entities with legacy public type names
Loading

Possibly related PRs

  • openmeterio/openmeter#5486: Both changes define how notification event type values are read across legacy and versioned stored representations.

Suggested reviewers: borosr, gergely-kurucz-konghq, galexihu

Merge Risk: Minimal · up to e5cae

This change lets notification rules and events be read whether their types are stored under legacy or versioned names. Writes and public output keep the legacy names, and filtering and sorting treat both spellings as the same type. No concrete defects were found, and the change is low risk to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the notification adapter now reads versioned event type names while keeping legacy names for writes. The changeset matches this. The title is 77 characters, which is w…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the notification adapter now reads versioned event type names while keeping legacy names for writes. The changeset matches this. The title is 77 characters, which is within a reasonable length for a single-sentence title.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 635c88f and e5cae56.

Files selected for processing: 7

  • openmeter/notification/README.md
  • openmeter/notification/adapter/entitymapping.go
  • openmeter/notification/adapter/event.go
  • openmeter/notification/adapter/event_test.go
  • openmeter/notification/adapter/rule.go
  • openmeter/notification/adapter/rule_test.go
  • openmeter/notification/service/event_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@chrisgacsal chrisgacsal added the release-note/misc Miscellaneous changes label Nov 16, 2026
@chrisgacsal
chrisgacsal marked this pull request as ready for review November 16, 2026 14:19
@chrisgacsal
chrisgacsal requested a review from a team as a code owner November 16, 2026 14:19
@chrisgacsal
chrisgacsal merged commit 890e6dc into main Nov 16, 2026
32 checks passed
@chrisgacsal
chrisgacsal deleted the feat/notification-event-type-compatibility branch November 16, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/misc Miscellaneous changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants