Skip to content

feat(router): add SubscriptionOnCreate hook#2972

Open
dkorittki wants to merge 18 commits into
mainfrom
dominik/new_subscriptionOnTrigger_hook
Open

feat(router): add SubscriptionOnCreate hook#2972
dkorittki wants to merge 18 commits into
mainfrom
dominik/new_subscriptionOnTrigger_hook

Conversation

@dkorittki

@dkorittki dkorittki commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Corresponding change in engine: wundergraph/graphql-go-tools#1538

Reviewer notes

Good review starting point is here . This is where the engine calls the new hook.
The type definition for the Custom Module Handler is here.

In general this changes:

  • Pubsub datasource implements the engines new interface resolve.HookablePubsubDatasource by adding the method SubscriptionOnCreate. This method executes the proper custom modules registered by the user.
  • Add docs to docs-website for the new hook
  • Add unit tests for the new hook
  • Add integration tests for the new hook

General context

Adds a new Cosmo Streams Custom Module SubscriptionOnCreate.
It allows to modify the subscription event configuration. Usecases for example are overwriting the Redis channels / Kafka topics / Nats subjects programmatically.
It is very similar to the existing SubscriptionOnStart but there are some differences:

  • It runs before a trigger is created while SubscriptionOnStart runs after
  • It does not allow to send custom data to subscriptions

Minimal usage example

func (m *CosmoStreamsModule) SubscriptionOnCreate(ctx core.SubscriptionBeforeTriggerHandlerContext) {
	// returns a pointer to cfg
	// cfg is thread-safe to modify and unique per request
	cfg := ctx.SubscriptionEventConfiguration()
	redisCfg, ok := cfg.(*redis.SubscriptionEventConfiguration)
	if !ok {
		return
	}

	redisCfg.Channels[0] = redisCfg.Channels[0] + "-modified" // modified in place
}

I marked this new handler as experimental to be able to change the handler in the future to be able to adapt to feedback from users.

Summary by CodeRabbit

  • New Features
    • Added an experimental “subscription on create” pub/sub lifecycle hook that runs before a subscription is registered, letting handlers inspect and modify subscription event configuration.
  • Improvements
    • Applies hook-updated configuration while preserving non-configuration fields, with compatibility validation and safety around failures (including panic recovery).
  • Documentation
    • Added a new custom-module documentation page and API description for SubscriptionOnCreateHandler.
  • Tests
    • Added integration and unit test coverage across NATS, Redis, and Kafka scenarios, including failure cases.
  • Chores
    • Updated GraphQL tools dependency version.

Checklist

Open Source AI Manifesto

This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a SubscriptionOnCreate lifecycle hook to the pubsub datasource and router module API, allowing user modules to intercept and mutate subscription event configuration before a trigger is created. New types define hook function signatures and context interfaces; PubSubSubscriptionDataSource implements the hook with panic recovery, handler invocation, type validation, and JSON config merging. The router detects modules implementing the new handler interface and wires them through the factory resolver into BuildProvidersAndDataSources. Comprehensive integration tests cover provider-specific routing mutations and failure modes across NATS, Redis, and Kafka. Documentation and dependency versions are updated.

Changes

Subscription On-Create Hook

Layer / File(s) Summary
Pubsub datasource hook types and SubscriptionOnCreate implementation
router/pkg/pubsub/datasource/hooks.go, router/pkg/pubsub/datasource/subscription_datasource.go
Adds SubscriptionOnCreateFn hook type, SubscriptionOnCreateHooks container, and SubscriptionOnCreate field on Hooks; implements PubSubSubscriptionDataSource.SubscriptionOnCreate with config unmarshaling, per-handler invocation under panic recovery, generic type compatibility validation, and JSON config merge via mergeConfigIntoInput that preserves non-config keys; updates compile-time interface assertion to resolve.HookablePubsubDatasource.
Datasource unit tests for SubscriptionOnCreate
router/pkg/pubsub/datasource/subscription_datasource_test.go
Introduces test configuration type for type-mismatch validation; adds tests covering no-hooks passthrough, multi-hook invocation, config mutation with chained propagation, type-incompatible returns, invalid JSON rejection, table-driven panic recovery, and handler list replacement semantics.
Router module hook API and subscription config
router/core/subscriptions_modules.go, router/core/router_config.go
Defines SubscriptionOnCreateHandlerContext interface, implements internal hook context, adds SubscriptionOnCreateHandler interface, and implements NewPubSubSubscriptionOnCreateHook adapter that enriches logger with provider/field metadata and returns mutated config or error; extends subscriptionHooks with onCreate field and onCreateHooks type.
Module registration and factory resolver wiring
router/core/router.go, router/core/factoryresolver.go
Router's initModules detects modules implementing SubscriptionOnCreateHandler and appends them to subscriptionHooks.onCreate; factory resolver wraps each handler with NewPubSubSubscriptionOnCreateHook and passes hooks into pubsub.BuildProvidersAndDataSources via Hooks.SubscriptionOnCreate.
Test module and integration tests
router-tests/modules/subscription-on-create/module.go, router-tests/modules/subscription_on_create_test.go
Introduces SubscriptionOnCreateModule test helper with optional callback and hook call counter; adds comprehensive suite verifying subject/channel/topic rewriting across NATS, Redis, and Kafka; tests targeted routing, fan-in/fan-out, panic recovery with GraphQL errors, and error-return abort behavior.
Documentation and dependency updates
docs-website/docs.json, docs-website/router/cosmo-streams/custom-modules.mdx, docs-website/router/cosmo-streams/custom-modules/subscription-on-create.mdx, router/go.mod, router-tests/go.mod
Adds comprehensive documentation page describing experimental hook lifecycle, constraints, context interface, and in-place mutation patterns with NATS/Redis examples; adds navigation entry and hook summary; updates graphql-go-tools to v2.4.7-0.20260616114425-40fb9ae23943.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

  • wundergraph/cosmo#2273: Extends the same Cosmo Streams hook framework by adding a new SubscriptionOnCreate hook lifecycle point alongside existing subscription hook infrastructure in the same router/core and router/pkg/pubsub/datasource layers.
  • wundergraph/cosmo#2059: Both PRs extend subscription lifecycle hooks via the same module API and factory resolver wiring: retrieved PR adds SubscriptionOnStart, main PR adds SubscriptionOnCreate into the same resolver/loader/datasource construction paths.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title accurately and concisely describes the main change: adding a SubscriptionOnCreate hook to the router.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.54217% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.29%. Comparing base (1658315) to head (f600b48).
⚠️ Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
router/core/subscriptions_modules.go 75.75% 7 Missing and 1 partial ⚠️
...r/pkg/pubsub/datasource/subscription_datasource.go 90.47% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2972       +/-   ##
===========================================
+ Coverage   46.83%   66.29%   +19.45%     
===========================================
  Files        1115      258      -857     
  Lines      151058    27640   -123418     
  Branches     9883        0     -9883     
===========================================
- Hits        70755    18324    -52431     
+ Misses      78501     7842    -70659     
+ Partials     1802     1474      -328     
Files with missing lines Coverage Δ
router/core/factoryresolver.go 80.45% <100.00%> (+0.22%) ⬆️
router/core/router.go 70.12% <100.00%> (-0.36%) ⬇️
router/core/router_config.go 93.82% <ø> (ø)
...r/pkg/pubsub/datasource/subscription_datasource.go 93.54% <90.47%> (-2.54%) ⬇️
router/core/subscriptions_modules.go 66.31% <75.75%> (+1.98%) ⬆️

... and 867 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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

🤖 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 `@router/pkg/pubsub/datasource/subscription_datasource.go`:
- Around line 97-121: The SubscriptionBeforeTrigger method has unnamed return
values, which prevents the deferred panic recovery from properly propagating
errors to the caller. When the defer block catches a panic and assigns the error
to the local err variable, the function still returns the original unnamed
return values instead of the recovered error. Change the method signature to use
named return values (output for the byte slice and err for the error) so that
when the defer block sets the err variable in the panic recovery handler, it
updates the actual return values that will be returned to the caller.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55ab7977-4282-4aed-b95d-416dfc61f88f

📥 Commits

Reviewing files that changed from the base of the PR and between 45eeeb7 and ee0b84b.

📒 Files selected for processing (6)
  • router/core/factoryresolver.go
  • router/core/router.go
  • router/core/router_config.go
  • router/core/subscriptions_modules.go
  • router/pkg/pubsub/datasource/hooks.go
  • router/pkg/pubsub/datasource/subscription_datasource.go

Comment thread router/pkg/pubsub/datasource/subscription_datasource.go Outdated
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

❌ Internal Query Planner CI checks failed

The Internal Query Planner CI checks failed in the celestial repository, and this is going to stop the merge of this PR.
If you are part of the WunderGraph organization, you can see the PR with more details.

@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.

♻️ Duplicate comments (1)
router/pkg/pubsub/datasource/subscription_datasource.go (1)

97-121: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Panic recovery does not propagate errors to callers.

SubscriptionBeforeCreate recovers panics, but with unnamed returns the recovered error isn’t returned; panic paths can exit as (nil, nil).

🔧 Suggested fix
-func (s *PubSubSubscriptionDataSource[C]) SubscriptionBeforeCreate(ctx context.Context, input []byte) ([]byte, error) {
+func (s *PubSubSubscriptionDataSource[C]) SubscriptionBeforeCreate(ctx context.Context, input []byte) (out []byte, err error) {
+	out = input
 	if len(s.hooks.SubscriptionBeforeCreate.Handlers) == 0 {
-		return input, nil
+		return out, nil
 	}
 
 	var (
 		conf SubscriptionEventConfiguration
-		err  error
 	)
@@
 			switch v := r.(type) {
 			case error:
 				err = v
 			default:
 				err = fmt.Errorf("%v", v)
 			}
+			out = nil
 		}
 	}()
@@
-	return mergeConfigIntoInput(input, conf)
+	out, err = mergeConfigIntoInput(input, conf)
+	return out, err
 }
🤖 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 `@router/pkg/pubsub/datasource/subscription_datasource.go` around lines 97 -
121, The SubscriptionBeforeCreate method uses unnamed return values but the
defer recovery block assigns to an err variable that is never returned to
callers. Change the function signature to use named return values so the err
variable assignment in the panic recovery defer block properly corresponds to
the returned error. This ensures that errors caught from panics are actually
propagated back to the caller instead of returning (nil, nil) when a panic
occurs.
🤖 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.

Duplicate comments:
In `@router/pkg/pubsub/datasource/subscription_datasource.go`:
- Around line 97-121: The SubscriptionBeforeCreate method uses unnamed return
values but the defer recovery block assigns to an err variable that is never
returned to callers. Change the function signature to use named return values so
the err variable assignment in the panic recovery defer block properly
corresponds to the returned error. This ensures that errors caught from panics
are actually propagated back to the caller instead of returning (nil, nil) when
a panic occurs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5ddc91f3-6cd5-4575-9135-c1ea31d73cd4

📥 Commits

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

⛔ Files ignored due to path filters (1)
  • router/go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • router/core/factoryresolver.go
  • router/core/router.go
  • router/core/router_config.go
  • router/core/subscriptions_modules.go
  • router/pkg/pubsub/datasource/hooks.go
  • router/pkg/pubsub/datasource/subscription_datasource.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • router/core/factoryresolver.go
  • router/core/subscriptions_modules.go

@dkorittki dkorittki force-pushed the dominik/new_subscriptionOnTrigger_hook branch from c1818c6 to a4e5564 Compare June 16, 2026 09:11
If a hook user can't create a new config, i.e. due to missing headers etc.,
let a hook user be able to return an error and stop the subscription from
being created.
@dkorittki dkorittki changed the title feat(router): add SubscriptionBeforeTrigger hook feat(router): add SubscriptionOnCreate hook Jun 16, 2026
@dkorittki dkorittki marked this pull request as ready for review June 16, 2026 14:21
@dkorittki dkorittki requested a review from a team as a code owner June 16, 2026 14:21
@dkorittki dkorittki requested a review from a team as a code owner June 16, 2026 14:21
@dkorittki

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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 (4)
router/pkg/pubsub/datasource/subscription_datasource_test.go (1)

703-710: ⚡ Quick win

Strengthen replacement-semantics assertion in SetSubscriptionOnCreateFns test.

The test currently asserts only length (1), which can still pass even if SetHooks fails to replace the previous handler instance. Assert identity/behavior of the active handler after the second SetHooks call.

Proposed test hardening
 	dataSource.SetHooks(Hooks{
 		SubscriptionOnCreate: SubscriptionOnCreateHooks{
 			Handlers: []SubscriptionOnCreateFn{hook2},
 		},
 	})
 	assert.Len(t, dataSource.hooks.SubscriptionOnCreate.Handlers, 1)
+	assert.Same(t, hook2, dataSource.hooks.SubscriptionOnCreate.Handlers[0])
🤖 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 `@router/pkg/pubsub/datasource/subscription_datasource_test.go` around lines
703 - 710, The test verifies the length of handlers remains 1 after calling
SetHooks with a new hook (hook2), but it does not verify that the handler was
actually replaced. After the second assert.Len call in the SetHooks block, add
an additional assertion to verify that the handler at index 0 in
dataSource.hooks.SubscriptionOnCreate.Handlers is actually hook2 (the new
handler that should have replaced the previous one). This ensures the
replacement semantics are correct and not just the count.
router-tests/modules/subscription_on_create_test.go (3)

690-690: 💤 Low value

Remove unnecessary blank assignment.

The constant sharedEmployeeID defined at line 597 is only used in the query string at line 598. The blank assignment _ = sharedEmployeeID at line 690 serves no purpose and can be removed to improve code clarity.

♻️ Suggested fix
 		wg.Wait()
 		xEnv.WaitForSubscriptionCount(0, subscriptionOnCreateTestTimeout)
-
-		_ = sharedEmployeeID
 	})
🤖 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 `@router-tests/modules/subscription_on_create_test.go` at line 690, Remove the
unnecessary blank assignment statement `_ = sharedEmployeeID` at line 690 in the
subscription_on_create_test.go file. Since the sharedEmployeeID constant is
already used in the query string earlier in the test and the blank assignment
serves no purpose, simply delete this line to improve code clarity.

463-519: ⚡ Quick win

Replace manual WaitGroup pattern with sync.WaitGroup.Go() across fan-in and fan-out tests. Based on learnings, Go 1.25+ code in this repository should use wg.Go(func()) instead of manual wg.Add(n) followed by go func() { defer wg.Done(); ... }(), as the former manages Add and Done automatically.

  • router-tests/modules/subscription_on_create_test.go#L463-L519: Replace var wg sync.WaitGroup; wg.Add(2) with var wg sync.WaitGroup, then replace both go func() { defer wg.Done(); ... }() blocks with wg.Go(func() { ... }).
  • router-tests/modules/subscription_on_create_test.go#L591-L642: Apply the same transformation: remove wg.Add(2) and replace both go func() { defer wg.Done(); ... }() blocks with wg.Go(func() { ... }).
🤖 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 `@router-tests/modules/subscription_on_create_test.go` around lines 463 - 519,
The code uses the manual WaitGroup pattern with explicit wg.Add() and defer
wg.Done() calls instead of the modern Go 1.25+ wg.Go() method. At
router-tests/modules/subscription_on_create_test.go lines 463-519, remove the
wg.Add(2) call and replace the two go func() { defer wg.Done(); ... }() blocks
with wg.Go(func() { ... }) calls, ensuring the function bodies remain unchanged.
Apply the identical transformation at
router-tests/modules/subscription_on_create_test.go lines 591-642, removing
wg.Add(2) and replacing both go func() { defer wg.Done(); ... }() blocks with
wg.Go(func() { ... }). The wg.Go() method automatically manages Add and Done
calls, eliminating boilerplate.

Source: Learnings


491-492: ⚡ Quick win

Remove manual SetReadDeadline before testenv.WSReadJSON in fan-in and fan-out tests. The coding guideline specifies that manual SetReadDeadline with raw conn.ReadJSON should only be used when expecting errors; testenv.WSReadJSON already handles deadlines with retry logic, so the manual deadline is redundant.

  • router-tests/modules/subscription_on_create_test.go#L491-L492: Remove conn.SetReadDeadline(time.Now().Add(time.Second * 5)) before testenv.WSReadJSON(t, conn, &complete).
  • router-tests/modules/subscription_on_create_test.go#L517-L518: Remove conn.SetReadDeadline(time.Now().Add(time.Second * 5)) before testenv.WSReadJSON(t, conn, &complete).
  • router-tests/modules/subscription_on_create_test.go#L617-L618: Remove conn.SetReadDeadline(time.Now().Add(time.Second * 5)) before testenv.WSReadJSON(t, conn, &complete).
  • router-tests/modules/subscription_on_create_test.go#L640-L641: Remove conn.SetReadDeadline(time.Now().Add(time.Second * 5)) before testenv.WSReadJSON(t, conn, &complete).
🤖 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 `@router-tests/modules/subscription_on_create_test.go` around lines 491 - 492,
Remove the redundant manual `SetReadDeadline` calls in
router-tests/modules/subscription_on_create_test.go at four locations before
`testenv.WSReadJSON` calls, since testenv.WSReadJSON already handles deadlines
with retry logic. At lines 491-492 (anchor site), remove the
`conn.SetReadDeadline(time.Now().Add(time.Second * 5))` line immediately before
the `testenv.WSReadJSON(t, conn, &complete)` call. Apply the same removal at
lines 517-518 (sibling site) before another `testenv.WSReadJSON(t, conn,
&complete)` call, at lines 617-618 (sibling site) before the same pattern, and
at lines 640-641 (sibling site) before the same pattern. In each case, simply
delete the SetReadDeadline line while keeping the testenv.WSReadJSON call.

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 `@router-tests/modules/subscription_on_create_test.go`:
- Line 690: Remove the unnecessary blank assignment statement `_ =
sharedEmployeeID` at line 690 in the subscription_on_create_test.go file. Since
the sharedEmployeeID constant is already used in the query string earlier in the
test and the blank assignment serves no purpose, simply delete this line to
improve code clarity.
- Around line 463-519: The code uses the manual WaitGroup pattern with explicit
wg.Add() and defer wg.Done() calls instead of the modern Go 1.25+ wg.Go()
method. At router-tests/modules/subscription_on_create_test.go lines 463-519,
remove the wg.Add(2) call and replace the two go func() { defer wg.Done(); ...
}() blocks with wg.Go(func() { ... }) calls, ensuring the function bodies remain
unchanged. Apply the identical transformation at
router-tests/modules/subscription_on_create_test.go lines 591-642, removing
wg.Add(2) and replacing both go func() { defer wg.Done(); ... }() blocks with
wg.Go(func() { ... }). The wg.Go() method automatically manages Add and Done
calls, eliminating boilerplate.
- Around line 491-492: Remove the redundant manual `SetReadDeadline` calls in
router-tests/modules/subscription_on_create_test.go at four locations before
`testenv.WSReadJSON` calls, since testenv.WSReadJSON already handles deadlines
with retry logic. At lines 491-492 (anchor site), remove the
`conn.SetReadDeadline(time.Now().Add(time.Second * 5))` line immediately before
the `testenv.WSReadJSON(t, conn, &complete)` call. Apply the same removal at
lines 517-518 (sibling site) before another `testenv.WSReadJSON(t, conn,
&complete)` call, at lines 617-618 (sibling site) before the same pattern, and
at lines 640-641 (sibling site) before the same pattern. In each case, simply
delete the SetReadDeadline line while keeping the testenv.WSReadJSON call.

In `@router/pkg/pubsub/datasource/subscription_datasource_test.go`:
- Around line 703-710: The test verifies the length of handlers remains 1 after
calling SetHooks with a new hook (hook2), but it does not verify that the
handler was actually replaced. After the second assert.Len call in the SetHooks
block, add an additional assertion to verify that the handler at index 0 in
dataSource.hooks.SubscriptionOnCreate.Handlers is actually hook2 (the new
handler that should have replaced the previous one). This ensures the
replacement semantics are correct and not just the count.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 03869d14-b864-459a-9604-e2d6a25558c3

📥 Commits

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

⛔ Files ignored due to path filters (2)
  • router-tests/go.sum is excluded by !**/*.sum
  • router/go.sum is excluded by !**/*.sum
📒 Files selected for processing (14)
  • docs-website/docs.json
  • docs-website/router/cosmo-streams/custom-modules.mdx
  • docs-website/router/cosmo-streams/custom-modules/subscription-on-create.mdx
  • router-tests/go.mod
  • router-tests/modules/subscription-on-create/module.go
  • router-tests/modules/subscription_on_create_test.go
  • router/core/factoryresolver.go
  • router/core/router.go
  • router/core/router_config.go
  • router/core/subscriptions_modules.go
  • router/go.mod
  • router/pkg/pubsub/datasource/hooks.go
  • router/pkg/pubsub/datasource/subscription_datasource.go
  • router/pkg/pubsub/datasource/subscription_datasource_test.go
✅ Files skipped from review due to trivial changes (1)
  • docs-website/router/cosmo-streams/custom-modules.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • router-tests/go.mod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants