Deprecate cloudevents messages#1118
Conversation
Signed-off-by: Albert Callarisa <albert@diagrid.io>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1118 +/- ##
==========================================
- Coverage 86.63% 82.22% -4.42%
==========================================
Files 84 116 +32
Lines 4473 9618 +5145
==========================================
+ Hits 3875 7908 +4033
- Misses 598 1710 +1112 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the dapr.ext.grpc pub/sub callback surface to support delivering the SDK-owned SubscriptionMessage to topic handlers (instead of leaking cloudevents.sdk.event.v1.Event), while preserving the legacy CloudEvents delivery path and emitting a deprecation warning for legacy handler signatures.
Changes:
- Added handler event-type inference based on the first parameter’s type annotation to choose between legacy
v1.Eventdelivery and newSubscriptionMessagedelivery. - Plumbed a
legacy_cloudeventflag through_CallbackServicerand added support for populatingSubscriptionMessage.metadata()from gRPC invocation metadata (and bulk entry metadata). - Updated examples and tests to use/validate
SubscriptionMessagedelivery and the deprecation behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/apps/pubsub_subscriber.py | Migrates integration subscriber to SubscriptionMessage and persists raw_data() |
| tests/ext/grpc/test_servicier.py | Adds coverage for legacy vs SubscriptionMessage delivery (single + bulk) including metadata |
| tests/ext/grpc/test_app.py | Adds tests for annotation-based inference and deprecation warnings |
| examples/pubsub-simple/subscriber.py | Updates example handlers to SubscriptionMessage APIs (data(), topic(), metadata()) |
| dapr/ext/grpc/app.py | Implements annotation inference + deprecation warning; wires legacy_cloudevent through registration |
| dapr/ext/grpc/AGENTS.md | Updates extension guidance/docs to prefer SubscriptionMessage and documents deprecation timeline |
| dapr/ext/grpc/_servicer.py | Adds dual delivery path (v1.Event vs SubscriptionMessage) and metadata plumbing (single + bulk) |
| dapr/ext/grpc/init.py | Re-exports SubscriptionMessage from the SDK common module |
| dapr/common/pubsub/subscription.py | Extends SubscriptionMessage with optional metadata and accessor |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Albert Callarisa <albert@diagrid.io>
Description
dapr.ext.grpctopic handlers have always received acloudevents.sdk.event.v1.Event. This PR deprecates that in favor of the SDK-ownedSubscriptionMessage, the same type the streaming subscription API (DaprClient.subscribe()) already delivers, as the first step toward removing thecloudeventsdependency from thegrpcextra entirely.Why
cloudeventslibrary purely as a data container: daprd does all CloudEvents enveloping/parsing and delivers pre-parsed fields over gRPC. No marshalling code is ever used.cloudevents.sdk.*tocloudevents.v1.sdk.*, which breaks both the extension and every user import (see the dependabot bump chore(deps): Bump cloudevents from 1.12.1 to 2.2.0 #1113). Upstream has moved 1.x to security-fixes-only support.Subject, and gRPC metadata was crammed into extensions as_metadata_*keys.SubscriptionMessagehas first-classtopic()/pubsub_name(), and gains ametadata()accessor here.How it works
The delivered type is inferred from the handler's event-parameter annotation, no new parameters on
App()orsubscribe():Backward compatibility
v1.Event) receive the exact samev1.Eventas before, byte-for-byte, plus oneDeprecationWarningper subscription at registration time (not per event).SubscriptionMessage.__init__gains an optionalmetadataparameter, additive; streaming API callers are unaffected (metadata()is empty there).Note for maintainers: deprecation timeline
The legacy cloudevents handler type is removed by 1.22: