Skip to content

feat(notification): prepare Channel storage for rolling upgrades - #5484

Merged
gergely-kurucz-konghq merged 3 commits into
mainfrom
feat/notification-phase1-channels
Nov 11, 2026
Merged

gergely-kurucz-konghq merged 3 commits into
mainfrom
feat/notification-phase1-channels

Conversation

@chrisgacsal

@chrisgacsal chrisgacsal commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

What

Prepare notification Channel storage for Phase 1 of the V4 migration. This is the first PR in the Channel → Rule → Event stack.

Why

Old and new backends share a database during a rolling deployment. Both must be able to read and update Channels throughout the rollout and after an application rollback.

How

  • Read both Channel type spellings and both webhook configuration shapes. Keep writes in the legacy uppercase, enveloped format and preserve the existing V1 and V3 API representations.
  • Add nullable event-type filters and provider data, plus inactive reconciliation fields. Existing Rule assignments still determine routing.
  • Exercise storage compatibility, filter semantics and migration defaults against PostgreSQL.

Summary by CodeRabbit

  • New Features
    • Webhook channel types now use consistent casing across the service and API, while existing stored formats remain supported.
    • Notification channels now track reconciliation status and scheduling details.
  • Bug Fixes
    • Invalid channel types and configurations are rejected with errors instead of being silently accepted.
    • Channel filters now support matching both current and legacy webhook type formats.
  • Documentation
    • Added guidance on channel storage compatibility and future routing and reconciliation considerations.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no blocking issues remain.

Summary

Prepares Channel storage for rolling upgrades while keeping legacy writes and the existing V1 and V3 API formats.

  • Channel reads accept both stored formats while writes keep the legacy shape.
  • Channel rows gain inactive fields for future routing and reconciliation.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  V1["V1 API: WEBHOOK"] --> Domain["Domain: webhook"]
  V3["V3 API: webhook"] --> Domain
  Domain --> Write["Write legacy type and config envelope"]
  Write --> DB[(Channel storage)]
  DB --> Read["Read either type spelling and config shape"]
  Read --> Domain
Loading

Reviews (3) · Last reviewed commit: "docs(notification): remove TODO from cha..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Files ignored due to path filters: 10

  • openmeter/ent/db/migrate/schema.go is excluded by !**/ent/db/**
  • openmeter/ent/db/mutation.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel/notificationchannel.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/runtime.go is excluded by !**/ent/db/**
  • openmeter/ent/db/setorclear.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum
Run configuration

Commits

Reviewing files that changed from the base of the PR and between b0bbadf and b0bbadf.

Files ignored due to path filters: 10

  • openmeter/ent/db/migrate/schema.go is excluded by !**/ent/db/**
  • openmeter/ent/db/mutation.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel/notificationchannel.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/runtime.go is excluded by !**/ent/db/**
  • openmeter/ent/db/setorclear.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The PR changes webhook channel type handling across API and storage boundaries, adds channel metadata and reconciliation fields, and supports legacy-envelope and flat webhook configuration reads. Mapping errors now propagate through channel, rule, and event reads.

Changes: Notification channel compatibility

Layer / File(s) Summary
Channel type contracts and API boundaries
openmeter/notification/channel.go, openmeter/notification/httpdriver/*, openmeter/notification/service/channel_test.go, api/v3/handlers/notification/channels/*
The domain webhook type is now lowercase. HTTP request mapping validates API channel types and response mapping converts them explicitly. V3 handler comments and tests use lowercase domain values.
Channel storage compatibility and reserved fields
openmeter/ent/schema/notification.go, openmeter/notification/adapter/channel.go, openmeter/notification/adapter/channel_test.go, tools/migrate/migrations/20261110143316_notification_channel_compatibility.*.sql, openmeter/notification/README.md, notifications-todo.md
The schema and migration add event filter, provider data, generation, and reconciliation fields. The adapter maps canonical webhook filters to both stored spellings and writes webhook configs in the legacy envelope format. Tests cover field preservation and migration defaults. Documentation records type/config formats and reconciliation follow-ups.
Configuration decoding and read error propagation
openmeter/notification/adapter/channel.go, openmeter/notification/adapter/entitymapping.go, openmeter/notification/adapter/rule.go, openmeter/notification/adapter/{event,rule}_test.go
The adapter accepts legacy-envelope and flat webhook configs. Channel, rule, and event mappings return configuration errors to their callers. Tests cover valid flat configs and malformed stored configs across read paths.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant EventFromDBEntity
  participant RuleFromDBEntity
  participant ChannelFromDBEntity
  participant fromDBChannelConfig
  EventFromDBEntity->>RuleFromDBEntity: map event rule
  RuleFromDBEntity->>ChannelFromDBEntity: map linked channel
  ChannelFromDBEntity->>fromDBChannelConfig: decode stored config
  fromDBChannelConfig-->>ChannelFromDBEntity: config or decoding error
  ChannelFromDBEntity-->>RuleFromDBEntity: channel or mapping error
  RuleFromDBEntity-->>EventFromDBEntity: rule or mapping error
Loading

Possibly related PRs

  • openmeterio/openmeter#5351: Defines Notification V4 channel provider contracts and provider data, which relates to the fields this PR adds to channel storage.
  • openmeterio/openmeter#5401: Refactors V4 provider contracts and defines provider data as map[string]string, related to this PR’s provider_data storage field.
  • openmeterio/openmeter#5352: Implements the V4 Svix provider, which uses channel event-type routing and provider data.

Suggested labels: kind/feature, release-note/feature

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

Merge Risk: Minimal · previous review b70d6

This change prepares Channel storage for rolling upgrades while keeping the legacy write formats and existing API representations. I found no concrete merge-blocking risk in the supplied change.

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 clearly summarizes the main change: preparing notification Channel storage for rolling upgrades.
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.
Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
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 391ef4a and b70d6b2.

Files ignored due to path filters: 10

  • openmeter/ent/db/migrate/schema.go is excluded by !**/ent/db/**
  • openmeter/ent/db/mutation.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel/notificationchannel.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/notificationchannel_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/runtime.go is excluded by !**/ent/db/**
  • openmeter/ent/db/setorclear.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum
Files selected for processing: 19

  • api/v3/handlers/notification/channels/convert.go
  • api/v3/handlers/notification/channels/convert_test.go
  • api/v3/handlers/notification/channels/list.go
  • notifications-todo.md
  • openmeter/ent/schema/notification.go
  • openmeter/notification/README.md
  • openmeter/notification/adapter/channel.go
  • openmeter/notification/adapter/channel_test.go
  • openmeter/notification/adapter/entitymapping.go
  • openmeter/notification/adapter/event_test.go
  • openmeter/notification/adapter/rule.go
  • openmeter/notification/adapter/rule_test.go
  • openmeter/notification/channel.go
  • openmeter/notification/httpdriver/channel.go
  • openmeter/notification/httpdriver/mapping.go
  • openmeter/notification/httpdriver/mapping_test.go
  • openmeter/notification/service/channel_test.go
  • tools/migrate/migrations/20261110143316_notification_channel_compatibility.down.sql
  • tools/migrate/migrations/20261110143316_notification_channel_compatibility.up.sql

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 marked this pull request as ready for review November 10, 2026 15:19
@chrisgacsal
chrisgacsal requested a review from a team as a code owner November 10, 2026 15:19
@chrisgacsal
chrisgacsal enabled stacked auto-merge (squash) November 10, 2026 15:21
@chrisgacsal
chrisgacsal disabled stacked auto-merge November 11, 2026 09:47
@chrisgacsal
chrisgacsal added this pull request to stack #5490 November 11, 2026 09:47
@gergely-kurucz-konghq
gergely-kurucz-konghq merged commit 27de566 into main Nov 11, 2026
32 checks passed
@gergely-kurucz-konghq
gergely-kurucz-konghq deleted the feat/notification-phase1-channels branch November 11, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor Code refactor, cleanup or minor improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants