Skip to content

fix(database): guard against undefined params in databaseBridge providers#1924

Merged
piorpua merged 1 commit intomainfrom
fix/sentry-ELECTRON-FN
Mar 30, 2026
Merged

fix(database): guard against undefined params in databaseBridge providers#1924
piorpua merged 1 commit intomainfrom
fix/sentry-ELECTRON-FN

Conversation

@kaizhou-lab
Copy link
Copy Markdown
Collaborator

Summary

  • Guard all three ipcBridge.database.* provider callbacks in databaseBridge.ts against undefined parameters by accepting params as a variable and using nullish coalescing (?? {}) before destructuring
  • Add unit tests verifying each provider handles undefined params without throwing

Sentry Issue

ELECTRON-FNTypeError: Cannot read properties of undefined (reading 'page')

  • Occurrences: 4
  • Culprit: databaseBridge.ts:26getUserConversations provider
  • Root cause: WebSocket can deliver messages with undefined data payload; destructuring undefined throws TypeError
  • Release: v1.9.2

Test plan

  • Added unit tests for all three providers with undefined params
  • All 12 databaseBridge tests pass
  • bunx tsc --noEmit passes
  • bun run lint:fix — 0 errors
  • bun run format — clean

…ders

When the WebSocket sends a message with no data payload, the provider
callbacks in databaseBridge receive undefined as their parameter. Destructuring
undefined throws TypeError: Cannot read properties of undefined.

Accept params as a variable first, then use nullish coalescing (?? {}) before
destructuring to safely handle undefined payloads.

Fixes ELECTRON-FN
@kaizhou-lab kaizhou-lab marked this pull request as ready for review March 30, 2026 08:40
@piorpua piorpua added the bot:reviewing Review in progress (mutex) label Mar 30, 2026
@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

Code Review:fix(database): guard against undefined params in databaseBridge providers (#1924)

变更概述

此 PR 修复 Sentry 线上 Bug(ELECTRON-FN):WebSocket 消息携带 undefined 数据载荷时,databaseBridge.ts 中三个 provider 的解构赋值直接崩溃,导致 TypeError: Cannot read properties of undefined。修复方式是将参数改为先接收 _params,再用 ?? {} 守卫后解构。变更涉及 src/process/bridge/databaseBridge.ts 和对应单元测试文件。


方案评估

结论:✅ 方案合理

三处修复模式一致、最小化改动:_params ?? {} 是 TypeScript 守卫 undefined 解构的惯用写法,不引入额外层次。当 conversation_id / keywordundefined 时会透传给 repo,但已有 try-catch 兜底,不会引发新的未处理异常。方案与项目架构完全一致,没有更优路径。


问题清单

未发现需要报告的问题。代码逻辑正确,边界处理合理,测试覆盖了全部三个 provider 的 undefined 场景,lint 警告均为测试文件中预存的 any 用法,与本 PR 无关。


汇总

无问题。

结论

批准合并 — 无阻塞性问题,修复精准,测试完备,CI 全部通过。


本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。

CONCLUSION: APPROVED
IS_CRITICAL_PATH: false
PR_NUMBER: 1924

@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

✅ 已自动 review,无阻塞性问题,正在触发自动合并。

@piorpua piorpua merged commit 23a0522 into main Mar 30, 2026
17 checks passed
@piorpua piorpua deleted the fix/sentry-ELECTRON-FN branch March 30, 2026 10:28
@piorpua piorpua added bot:done Auto-merged by bot and removed bot:reviewing Review in progress (mutex) labels Mar 30, 2026
wuhao1477 added a commit to wuhao1477/AionUi that referenced this pull request Mar 30, 2026
* 'main' of github.com:wuhao1477/AionUi: (40 commits)
  fix(agents): prevent unhandled promise rejection in bootstrap initialization (iOfficeAI#1933)
  fix(gemini): restore context after stopping a reply (iOfficeAI#1932)
  fix(codex): reject start promise immediately on process exit during startup (iOfficeAI#1929)
  fix(conversation): sync renamed titles with detail view (iOfficeAI#1927)
  fix(paste): deduplicate filenames when pasting multiple images simultaneously
  fix(mobile): add SafeArea support and update app icon (iOfficeAI#1926)
  fix(database): guard against undefined params in databaseBridge providers (iOfficeAI#1924)
  fix(conversation): validate type field before creating conversation (iOfficeAI#1921)
  fix(docs): restore wechat_group_5.png reference to wx-5.png in readme
  fix(snapshot): add maxBuffer to git add/commit exec calls (iOfficeAI#1914)
  refactor(acp): consolidate AGENT_SKILLS_DIRS into ACP_BACKENDS_ALL (iOfficeAI#1913)
  fix(gemini): guard against EACCES in workspace realpath during init (ELECTRON-BM) (iOfficeAI#1912)
  fix(channels): send raw QR ticket instead of page URL in WeChat WebUI login SSE (iOfficeAI#1910)
  .md format
  chore(pr-automation): fix missed sleep 5 in comment to sleep 10
  chore(pr-automation): increase auto-merge retry delay to 10s
  chore(pr-automation): add 5s retry for transient GitHub mergeStateStatus UNKNOWN
  fix(docs): remove trailing whitespace in OfficeCLI readmes
  chore(pr-automation): verify auto-merge success before labeling bot:done
  fix(snapshot): guard against non-existent workspace in WorkspaceSnapshotService.init (iOfficeAI#1906)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:done Auto-merged by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants