You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Confidence 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.
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.
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.
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.
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.
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: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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.
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.
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
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.
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.
invoice.createdv1.billing.invoice.createdinvoice.updatedv1.billing.invoice.updatedentitlements.balance.thresholdv1.entitlement.balance_threshold.triggeredentitlements.resetv1.entitlement.usage_period.resetNotes 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.


Confidence 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.
Reviews (2) · Last reviewed commit: "refactor(notification): keep event type ..." · Reviewed by Greptile
Summary by CodeRabbit