fix(bridge): guard against undefined params in sendMessage provider#1909
Merged
fix(bridge): guard against undefined params in sendMessage provider#1909
Conversation
WebSocket messages without a data payload cause TypeError when destructuring conversation_id from undefined. Add null check before destructuring to return a graceful error response. Fixes ELECTRON-FK
Contributor
Code Review:fix(bridge): guard against undefined params in sendMessage provider (#1909)变更概述此 PR 修复了 Sentry 高频错误 ELECTRON-FK(1天85次): 方案评估结论:✅ 方案合理 修复精准、最小侵入, 问题清单🔵 LOW — 测试 mock 使用
|
| # | 严重级别 | 文件 | 问题 |
|---|---|---|---|
| 1 | 🔵 LOW | conversationBridge.sendMessage.test.ts:100,106 |
as any lint 警告 |
结论
✅ 批准合并 — 无阻塞性问题
修复逻辑正确,测试覆盖了触发 Sentry 的核心路径,仅有 2 处测试文件的 lint 警告(LOW),不阻塞合并。
本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。
CONCLUSION: APPROVED
IS_CRITICAL_PATH: false
PR_NUMBER: 1909
Contributor
|
✅ 已自动 review,无阻塞性问题,正在触发自动合并。 |
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
undefinedparams inipcBridge.conversation.sendMessage.providercallbackdatapayload (e.g.bypassPermissions) causeTypeError: Cannot destructure property 'conversation_id' of 'undefined'{ success: false, msg: 'Missing request parameters' }instead of crashingSentry Issue
ELECTRON-FK — 85 events in 1 day, escalating
TypeError: Cannot destructure property 'conversation_id' of 'undefined' as it is undefined.src/process/bridge/conversationBridge.ts:397(sendMessage.provider)Root Cause
The
WebSocketManagerparses incoming messages as{ name, data }. When a message has a validnamebut nodatafield,dataisundefined. This flows throughadapter.ts→@office-ai/platformbridge →sendMessage.providercallback, where destructuring{ conversation_id, files, ...other }fromundefinedthrows aTypeError.Fix
Add a null/undefined check at the top of the provider callback before destructuring.
Test Plan
undefinedparams returns error responsenullparams returns error responsebunx tsc --noEmitpassesbun run lint:fix— no errorsbun run test— all relevant tests pass (pre-existingpreviewFileWatch.dom.test.tsfailures unrelated)