Skip to content

fix(router): ignore nil events (Cosmo Streams)#2315

Merged
dkorittki merged 3 commits intotopic/streams-v1from
dominik/eng-8440-prevent-panic-on-nil-events
Oct 31, 2025
Merged

fix(router): ignore nil events (Cosmo Streams)#2315
dkorittki merged 3 commits intotopic/streams-v1from
dominik/eng-8440-prevent-panic-on-nil-events

Conversation

@dkorittki
Copy link
Copy Markdown
Contributor

@dkorittki dkorittki commented Oct 31, 2025

Checklist

I made sure that for the OnReceiveEvent and OnPublishEvent hook we do not pass nil events to the engine, which can cause panics.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced null event handling in message publishing and subscription updates. The system now properly filters and ignores null events during processing, improving system stability and preventing potential edge-case errors.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 31, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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

Walkthrough

The changes introduce nil-event filtering in the publish and subscription update paths to handle nil StreamEvent entries produced by stream publish and batch hooks. Production code adds defensive nil guards and post-processing filters, while tests are updated to verify this behavior.

Changes

Cohort / File(s) Summary
Publish event filtering
router/pkg/pubsub/datasource/pubsubprovider.go
Added slices package import. Modified Publish to filter nil StreamEvent entries from applyPublishEventHooks results using slices.DeleteFunc before passing to Adapter.Publish.
Subscription event nil-skip
router/pkg/pubsub/datasource/subscription_event_updater.go
Added nil-event guard in the per-subscription update loop to skip nil entries before calling UpdateSubscription.
Test updates
router/pkg/pubsub/datasource/pubsubprovider_test.go, router/pkg/pubsub/datasource/subscription_event_updater_test.go
Extended hook tests with nil event placeholders and updated assertions to verify nil entries are filtered/ignored during processing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Straightforward defensive nil-checking pattern applied consistently across two files
  • Low logic density; changes are localized to specific function paths
  • Test updates mirror production changes with repetitive nil-event assertions
  • Minimal risk of control flow or error handling disruption

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "fix(router): ignore nil events (Cosmo Streams)" directly and accurately reflects the primary change across all modified files. The changeset consistently adds logic to filter and skip nil events in the publisher (pubsubprovider.go) and subscription event updater (subscription_event_updater.go), with corresponding test updates. The title is concise, specific, and clearly communicates that the fix addresses nil event handling to prevent panics, which aligns with the PR's stated objective to ensure hooks do not pass nil events to the engine.

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 and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Oct 31, 2025

Router-nonroot image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-534341f703b641ed2d4250afdd74fd088a395544-nonroot

@dkorittki
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 31, 2025

✅ Actions performed

Review triggered.

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.

Comment thread router/pkg/pubsub/datasource/pubsubprovider.go Outdated
@dkorittki dkorittki merged commit e6169f3 into topic/streams-v1 Oct 31, 2025
24 checks passed
@dkorittki dkorittki deleted the dominik/eng-8440-prevent-panic-on-nil-events branch October 31, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants