fix(model-bridge): validate apiKey before creating OpenAI client in new-api branch#1758
Merged
fix(model-bridge): validate apiKey before creating OpenAI client in new-api branch#1758
Conversation
da72d65 to
5b4d724
Compare
…ew-api branch The isNewApiPlatform code path created a new OpenAI client without checking if actualApiKey was truthy, causing an unhandled "Missing credentials" rejection (ELECTRON-6X, 7080 occurrences). Add an early return with a user-friendly error message, matching the existing guard on the general OpenAI path. Add unit tests covering empty and undefined apiKey for the new-api platform.
5b4d724 to
2d94752
Compare
Contributor
Code Review:fix(model-bridge): validate apiKey before creating OpenAI client in new-api branch (#1758)变更概述本 PR 针对 Sentry 问题 ELECTRON-6X(7080 次出现)进行修复:在 方案评估结论:✅ 方案合理 修复方案直接镜像了第 365-368 行已有的通用 OpenAI 路径守卫逻辑,做到了代码一致性。使用 问题清单未发现任何问题。 Lint 基准说明:oxlint 输出的 27 条警告全部来自文件中已有代码( 汇总
结论✅ 批准合并 — 修复精准,测试覆盖完整,与项目已有守卫模式高度一致,无任何阻塞性问题。 本报告由本地 |
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
actualApiKeybefore constructingnew OpenAI()in theisNewApiPlatformbranch to prevent unhandled "Missing credentials" rejectionChanges
src/process/bridge/modelBridge.tsactualApiKeyis falsy in theisNewApiPlatformcode path (mirrors existing guard at line 361 for the general OpenAI path)tests/unit/bridge/modelBridge.test.tsplatform: 'new-api'Related Issue
Closes #1757
Sentry: ELECTRON-6X — 7080 occurrences, regressed
Verification
Test Plan
{ success: false }for new-api platform{ success: false }for new-api platform