fix(asr): 火山渠道「验证」接入真实 WS 连通检查,修复必报「API Key 为空」 - #944
Merged
H-Chris233 merged 2 commits intoAug 12, 2026
Conversation
validate_asr_provider 此前没有火山分支,火山渠道点「验证」会掉进 OpenAI 兼容 HTTP 兜底——那条路只认 asr.api_key(火山从不写入的槽位),导致无论 哪种鉴权模式、凭据填得多对,连接检查都报「API Key 为空」。 - 新增 validate_volcengine_asr_provider:按鉴权模式取各自槽位凭据 (旧版 volcengine.access_key / 新版控制台 volcengine.api_key), 真连官方 WS 端点 + 1s 静音 + 收尾,与讯飞验证器同构;纯静音会话 服务端不回 final(NoFinalResult)不算失败——握手成功已证明凭据有效 - 凭据缺失按模式返回哨兵串(volcengineAppIdMissing 等),前端映射为 多语言文案,直接指出该补哪个输入框(en/ja/ko/zh-CN/zh-TW 同步) - 握手被拒(401/403)/ 被限流(429)的报错原样透传给验证按钮, 不再折叠成笼统的「操作失败」 - 补 volcengine_missing_credential_error 单测锁定两种模式的判定 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
|
妈呀我还不知道有这么大漏洞 |
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.
问题
火山引擎 bigasr 渠道的「验证」按钮从来没通过过:无论选旧版(APP ID + Access Token)还是新版控制台(API Key)模式、凭据填得多对,点「验证」都立刻报「API Key 为空」。用户会以为自己配置错了,反复检查凭据——其实实际听写一直是正常的,坏的只是连接检查本身。
原因
validate_asr_provider里百炼、讯飞、StepFun、ElevenLabs 各有专属验证分支,唯独没有火山的。火山渠道于是掉进 OpenAI 兼容 HTTP 兜底,而那条路只认asr.api_key——火山从不写入的通用槽位(火山凭据存在volcengine.*专属槽位),所以第一步就空 Key 报错。渠道卡片化(#918)给每张卡都加上「验证」按钮后,这个洞暴露给了所有火山用户。修复
给火山加上与讯飞同构的专属验证器:按当前鉴权模式取各自槽位的凭据,真连官方 WS 端点 + 1s 静音探针 + 收尾。凭据没填时按模式精确提示缺哪一项(APP ID / Access Token / API Key,五语言同步);握手被拒(401/403)或被限流(429)时把带状态码的报错原样透传,不再折叠成「操作失败」。
技术细节
validate_asr_provider新增volcengine分支 →validate_volcengine_asr_provider:read_volc_credentials同规则):AppIdToken 读volcengine.app_key+volcengine.access_key,ApiKey 读volcengine.api_key,互不污染;Resource ID 空时回落默认volc.seedasr.sauc.durationVolcengineStreamingASR(生产同款客户端):open_session→ 5×200ms 静音 chunk →send_last_frame→await_final_result;NoFinalResult视为通过(纯静音会话服务端可能不回 final,握手成功已证明凭据有效,与讯飞验证器同判定)AuthRejected)/ 限流(RateLimited)在握手阶段即返回,验证通常 1~2 秒内出结果volcengineAppIdMissing/volcengineAccessTokenMissing/volcengineApiKeyMissing),前端providerErrorMessage映射多语言文案;volcengine.rs的TARGET_AUDIO_CHUNK_BYTES放开为pub(crate)供验证器复用volcengine_missing_credential_error_follows_auth_mode锁定两种模式的凭据判定(trim 语义与VolcengineAuthMode::auth_ok一致)验证:
cargo check通过;cargo test volcengine(13 项)与cargo test commands::providers(18 项)全绿;tsc --noEmit+ 前端测试套件通过。🤖 Generated with Claude Code