fix(messaging): resolve message-to-event 404 for outgoing events without incomingEventId#1859
Open
mnbreno wants to merge 1 commit intobotpress:masterfrom
Open
fix(messaging): resolve message-to-event 404 for outgoing events without incomingEventId#1859mnbreno wants to merge 1 commit intobotpress:masterfrom
mnbreno wants to merge 1 commit intobotpress:masterfrom
Conversation
…out incomingEventId The `/message-to-event/:messageId` route returns 404 for outgoing events that lack an `incomingEventId` (63% of outgoing events in production). Root cause: the handler unconditionally looks up an incoming event using `messageEvent.incomingEventId`, which is empty for most outgoing events (proactive messages, integration replies, etc.). Fix: - If the matched event is already incoming, return it directly. - If outgoing with a linked incomingEventId, follow the chain (existing behavior, preserved). - Otherwise, return the outgoing event itself as graceful degradation instead of 404. This eliminates spurious 404s from Studio/HITL debugger polling without changing behavior for events that already have the link set. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/v1/bots/:botId/messaging/message-to-event/:messageIdendpoint returns 404 for outgoing events that lackincomingEventId. In production, 63% of outgoing events (26/41) have this field empty, causing constant spurious 404s in Studio and HITL debugger.findEvents({ incomingEventId: ... })lookup, which fails when the field is empty/null.incomingEventId→ follow the chain (existing behavior, preserved).Changed file
packages/bp/src/core/messaging/messaging-bot-router.ts— 18 insertions, 8 deletions in the/message-to-event/:messageIdroute handler.Reproduction
404onmessage-to-event/<messageId>in the network tab for outgoing (bot-reply) messages.SELECT direction, "incomingEventId" FROM events WHERE "messageId" = '<uuid>';— outgoing events have emptyincomingEventId.Test plan
incomingEventId→ returns 200 + event JSON (was 404).incomingEventId→ returns 200 + incoming event JSON (unchanged behavior).message-to-eventafter fix.Made with Cursor