-
Notifications
You must be signed in to change notification settings - Fork 2
Fix handling channel events that don't match triggers so that events are still persisted #768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes event persistence for channel events that don't match any triggers by restructuring the event handling logic to persist events before checking for matching triggers.
- Refactored event handling to convert channel events to engine events before trigger matching
- Moved event persistence logic to occur regardless of trigger matching
- Simplified trigger finding logic to work with actual event objects
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
core/tasks/realtime/ctasks/event_received.go | Restructured event handling to persist events before trigger matching and added event conversion function |
core/tasks/realtime/ctasks/event_received_test.go | Updated test expectations to reflect that events are now persisted even when no triggers match |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
switch typed := evt.(type) { | ||
case *events.ChatStarted: | ||
if referrerID := typed.Params["referrer_id"]; referrerID != "" { | ||
mtrig = models.FindMatchingReferralTrigger(oa, ch, referrerID) | ||
} else { | ||
mtrig = models.FindMatchingNewConversationTrigger(oa, ch) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential nil pointer dereference. The typed.Params
map could be nil, which would cause a panic when accessing typed.Params["referrer_id"]
. Add a nil check before accessing the map.
Copilot uses AI. Check for mistakes.
default: | ||
return nil, "", fmt.Errorf("unknown channel event type: %s", t.EventType) | ||
return nil, "", fmt.Errorf("unknown event type: %s", t.EventType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message references t.EventType
but the function is now switching on the actual event type (evt
). This will show the original model event type rather than the specific event type that failed to match, making debugging more difficult.
return nil, "", fmt.Errorf("unknown event type: %s", t.EventType) | |
return nil, "", fmt.Errorf("unknown event type: %T", evt) |
Copilot uses AI. Check for mistakes.
e24fe99
to
61a8192
Compare
…are still persisted
61a8192
to
8f6d333
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #768 +/- ##
==========================================
+ Coverage 50.96% 51.03% +0.07%
==========================================
Files 250 250
Lines 15132 15153 +21
==========================================
+ Hits 7712 7734 +22
- Misses 6612 6615 +3
+ Partials 808 804 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.