Skip to content

Conversation

rowanseymour
Copy link
Member

No description provided.

@Copilot Copilot AI review requested due to automatic review settings August 28, 2025 20:31
Copy link

@Copilot Copilot AI left a 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.

Comment on lines 158 to 200
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)
}
Copy link
Preview

Copilot AI Aug 28, 2025

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)
Copy link
Preview

Copilot AI Aug 28, 2025

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.

Suggested change
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.

@rowanseymour rowanseymour force-pushed the event_received_fix branch 2 times, most recently from e24fe99 to 61a8192 Compare August 28, 2025 20:42
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 69.73684% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.03%. Comparing base (5bcbbe2) to head (8f6d333).

Files with missing lines Patch % Lines
core/tasks/realtime/ctasks/event_received.go 69.73% 19 Missing and 4 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rowanseymour rowanseymour merged commit 8c7e727 into main Aug 28, 2025
5 checks passed
@rowanseymour rowanseymour deleted the event_received_fix branch August 28, 2025 20:55
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants