Skip to content

move event gw db to new schema#2650

Merged
tharindu1st merged 1 commit into
wso2:mainfrom
tharindu1st:aws-authentication
Jul 15, 2026
Merged

move event gw db to new schema#2650
tharindu1st merged 1 commit into
wso2:mainfrom
tharindu1st:aws-authentication

Conversation

@tharindu1st

Copy link
Copy Markdown
Contributor

move event gw db to new schema

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@tharindu1st, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dce82a7f-d4f2-40f2-ac6a-ec8cf9d51a5a

📥 Commits

Reviewing files that changed from the base of the PR and between bab1ae1 and 36f34b6.

⛔ Files ignored due to path filters (1)
  • go.work.sum is excluded by !**/*.sum
📒 Files selected for processing (20)
  • event-gateway/gateway-controller/cmd/controller/main.go
  • event-gateway/gateway-controller/pkg/controlplanehooks/events.go
  • event-gateway/gateway-controller/pkg/controlplanehooks/hooks.go
  • event-gateway/gateway-controller/pkg/dbschema/dbschema.go
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.postgres.sql
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.sql
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.sqlserver.sql
  • event-gateway/gateway-controller/pkg/kindsupport/kindsupport.go
  • gateway/gateway-controller/cmd/controller/main.go
  • gateway/gateway-controller/pkg/api/handlers/handlers.go
  • gateway/gateway-controller/pkg/controlplane/client.go
  • gateway/gateway-controller/pkg/controlplane/eventgateway_hooks.go
  • gateway/gateway-controller/pkg/controlplane/events.go
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.postgres.sql
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.sql
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.sqlserver.sql
  • gateway/gateway-controller/pkg/storage/sql_store.go
  • gateway/gateway-controller/pkg/storage/sqlite_test.go
  • gateway/gateway-controller/pkg/utils/api_utils.go
  • gateway/gateway-controller/tests/integration/schema_test.go
📝 Walkthrough

Walkthrough

Event-gateway schemas, storage registration, control-plane hooks, lifecycle handlers, HMAC synchronization, and configuration-dump handling were added. Core schemas and event types were reassigned to the event-gateway module, while WebSub/WebBroker authorization route mappings were removed.

Changes

Event-Gateway integration

Layer / File(s) Summary
Schema ownership and startup application
event-gateway/gateway-controller/pkg/dbschema/*, event-gateway/gateway-controller/cmd/controller/main.go, gateway/gateway-controller/pkg/storage/gateway-controller-db.*
Event-gateway tables are defined per database dialect, applied during startup, and removed from core schema files.
Storage registration and resource fetching
event-gateway/gateway-controller/pkg/kindsupport/*, gateway/gateway-controller/pkg/storage/*, gateway/gateway-controller/pkg/utils/api_utils.go, gateway/gateway-controller/tests/*
WebSub and WebBroker resource tables are registered dynamically, configuration queries include registered tables, and generic authenticated ZIP/JSON fetch helpers are added.
Control-plane hook contract and dispatch
gateway/gateway-controller/pkg/controlplane/*, event-gateway/gateway-controller/pkg/controlplanehooks/events.go
Control-plane event DTOs, hook registration, client accessors, and dispatch routing are introduced for WebSub and WebBroker events.
API lifecycle and HMAC synchronization
event-gateway/gateway-controller/pkg/controlplanehooks/hooks.go, gateway/gateway-controller/pkg/utils/api_utils.go
Lifecycle callbacks validate events, update storage, send acknowledgments, clean up resources, and synchronize WebSub HMAC secrets.

Admin configuration dump

Layer / File(s) Summary
Configuration dump endpoint and aggregation
gateway/gateway-controller/pkg/api/handlers/handlers.go
Adds JSON configuration-dump generation with API, policy, certificate, statistics, xDS metadata, and sensitive-value redaction.
Management route role mapping
gateway/gateway-controller/cmd/controller/main.go
Removes WebSub and WebBroker management routes from generated default resource roles.

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

Sequence Diagram(s)

sequenceDiagram
  participant ControlPlaneClient
  participant Hooks
  participant APIUtilsService
  participant GatewayStorage
  participant EventHub
  ControlPlaneClient->>Hooks: Dispatch WebSub/WebBroker lifecycle event
  Hooks->>APIUtilsService: Fetch API definition ZIP or JSON secrets
  APIUtilsService-->>Hooks: Definition or secret data
  Hooks->>GatewayStorage: Update API state and secret references
  Hooks->>EventHub: Publish API update
  Hooks-->>ControlPlaneClient: Send deployment acknowledgment
Loading

Possibly related PRs

  • wso2/api-platform#2623: Moves WebSub/WebBroker event payload types into event-gateway control-plane hooks and aligns with the hook-based control-plane refactor.

Suggested reviewers: pubudu538, malinthaprasan, virajsalaka, anugayan, tharsanan1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is just a repeated title and omits all required template sections, so it is largely incomplete. Fill in the required Purpose, Goals, Approach, User stories, Documentation, tests, security checks, samples, related PRs, and test environment sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly summarizes the main change: moving the Event Gateway database to a new schema.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
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 unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
gateway/gateway-controller/pkg/utils/api_utils.go (1)

651-687: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Bound the response body with io.LimitReader before reading into memory.

FetchResourceZip (Line 677) and FetchResourceJSON (Line 714) read the network response body without an upper bound, so an unexpectedly large upstream payload could exhaust memory. Wrap the body in io.LimitReader with a configurable ceiling before io.ReadAll/Decode.

As per coding guidelines: "Wrap every user- or network-originated io.Reader in io.LimitReader before reading it into memory. Source the byte limit from configuration (environment variable or config file), provide a safe default, and do not hardcode the ceiling."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@gateway/gateway-controller/pkg/utils/api_utils.go` around lines 651 - 687,
The response bodies read by FetchResourceZip and FetchResourceJSON are
unbounded; wrap each network response body with io.LimitReader before io.ReadAll
or decoding. Source the maximum byte limit from configuration with a safe
default, rather than hardcoding it, and preserve the existing success and error
handling behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@gateway/gateway-controller/pkg/utils/api_utils.go`:
- Around line 651-687: The response bodies read by FetchResourceZip and
FetchResourceJSON are unbounded; wrap each network response body with
io.LimitReader before io.ReadAll or decoding. Source the maximum byte limit from
configuration with a safe default, rather than hardcoding it, and preserve the
existing success and error handling behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 63f0b092-a8da-4c69-ba24-6b5d7abd6420

📥 Commits

Reviewing files that changed from the base of the PR and between d16ad96 and 05d5947.

📒 Files selected for processing (20)
  • event-gateway/gateway-controller/cmd/controller/main.go
  • event-gateway/gateway-controller/pkg/controlplanehooks/events.go
  • event-gateway/gateway-controller/pkg/controlplanehooks/hooks.go
  • event-gateway/gateway-controller/pkg/dbschema/dbschema.go
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.postgres.sql
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.sql
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.sqlserver.sql
  • event-gateway/gateway-controller/pkg/kindsupport/kindsupport.go
  • gateway/gateway-controller/cmd/controller/main.go
  • gateway/gateway-controller/pkg/api/handlers/handlers.go
  • gateway/gateway-controller/pkg/controlplane/client.go
  • gateway/gateway-controller/pkg/controlplane/eventgateway_hooks.go
  • gateway/gateway-controller/pkg/controlplane/events.go
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.postgres.sql
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.sql
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.sqlserver.sql
  • gateway/gateway-controller/pkg/storage/sql_store.go
  • gateway/gateway-controller/pkg/storage/sqlite_test.go
  • gateway/gateway-controller/pkg/utils/api_utils.go
  • gateway/gateway-controller/tests/integration/schema_test.go
💤 Files with no reviewable changes (3)
  • gateway/gateway-controller/pkg/storage/sqlite_test.go
  • gateway/gateway-controller/cmd/controller/main.go
  • gateway/gateway-controller/pkg/api/handlers/handlers.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
gateway/gateway-controller/pkg/utils/api_utils.go (1)

658-658: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer http.NewRequestWithContext for outbound network calls.

Consider accepting a context.Context parameter in these helper functions to support timeouts and cancellations.

  • gateway/gateway-controller/pkg/utils/api_utils.go#L658-L658: Update to use http.NewRequestWithContext(ctx, "GET", url, nil).
  • gateway/gateway-controller/pkg/utils/api_utils.go#L695-L695: Update to use http.NewRequestWithContext(ctx, "GET", url, nil).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@gateway/gateway-controller/pkg/utils/api_utils.go` at line 658, Update both
outbound GET request sites in gateway/gateway-controller/pkg/utils/api_utils.go
at lines 658-658 and 695-695: have the containing helper functions accept a
context.Context parameter and use it with http.NewRequestWithContext for each
request, propagating the caller’s context to preserve timeout and cancellation
support.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@gateway/gateway-controller/pkg/utils/api_utils.go`:
- Around line 672-681: Limit all network response-body reads in
api_utils.go:672-681 and api_utils.go:709-717 by wrapping resp.Body with
io.LimitReader before io.ReadAll and json.NewDecoder; use a configured byte
limit from PlatformAPIConfig and add a safe default for these requests. Preserve
the existing success and error handling while applying the limit in every listed
path.

---

Nitpick comments:
In `@gateway/gateway-controller/pkg/utils/api_utils.go`:
- Line 658: Update both outbound GET request sites in
gateway/gateway-controller/pkg/utils/api_utils.go at lines 658-658 and 695-695:
have the containing helper functions accept a context.Context parameter and use
it with http.NewRequestWithContext for each request, propagating the caller’s
context to preserve timeout and cancellation support.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: eb50bc55-1b12-44f8-8945-4e9b14e0345c

📥 Commits

Reviewing files that changed from the base of the PR and between 05d5947 and bab1ae1.

📒 Files selected for processing (20)
  • event-gateway/gateway-controller/cmd/controller/main.go
  • event-gateway/gateway-controller/pkg/controlplanehooks/events.go
  • event-gateway/gateway-controller/pkg/controlplanehooks/hooks.go
  • event-gateway/gateway-controller/pkg/dbschema/dbschema.go
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.postgres.sql
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.sql
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.sqlserver.sql
  • event-gateway/gateway-controller/pkg/kindsupport/kindsupport.go
  • gateway/gateway-controller/cmd/controller/main.go
  • gateway/gateway-controller/pkg/api/handlers/handlers.go
  • gateway/gateway-controller/pkg/controlplane/client.go
  • gateway/gateway-controller/pkg/controlplane/eventgateway_hooks.go
  • gateway/gateway-controller/pkg/controlplane/events.go
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.postgres.sql
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.sql
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.sqlserver.sql
  • gateway/gateway-controller/pkg/storage/sql_store.go
  • gateway/gateway-controller/pkg/storage/sqlite_test.go
  • gateway/gateway-controller/pkg/utils/api_utils.go
  • gateway/gateway-controller/tests/integration/schema_test.go
💤 Files with no reviewable changes (3)
  • gateway/gateway-controller/pkg/storage/sqlite_test.go
  • gateway/gateway-controller/pkg/api/handlers/handlers.go
  • gateway/gateway-controller/cmd/controller/main.go
🚧 Files skipped from review as they are similar to previous changes (15)
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.postgres.sql
  • gateway/gateway-controller/pkg/controlplane/events.go
  • event-gateway/gateway-controller/cmd/controller/main.go
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.sqlserver.sql
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.sqlserver.sql
  • event-gateway/gateway-controller/pkg/kindsupport/kindsupport.go
  • event-gateway/gateway-controller/pkg/dbschema/eventgateway-db.sql
  • event-gateway/gateway-controller/pkg/dbschema/dbschema.go
  • gateway/gateway-controller/pkg/controlplane/client.go
  • event-gateway/gateway-controller/pkg/controlplanehooks/events.go
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.postgres.sql
  • gateway/gateway-controller/pkg/controlplane/eventgateway_hooks.go
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.sql
  • event-gateway/gateway-controller/pkg/controlplanehooks/hooks.go
  • gateway/gateway-controller/pkg/storage/sql_store.go

Comment thread gateway/gateway-controller/pkg/utils/api_utils.go
@tharindu1st
tharindu1st merged commit 4b054a1 into wso2:main Jul 15, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants