Repository navigation
fix(setup): 新建机器人补齐事件订阅与卡片回调——console 增量契约 + fail-closed - #472
Merged
Merged
Conversation
v2.109.0 起建 bot 改走开放平台 Web app/create(普通企业自建应用,默认零事件 订阅),而自动订阅事件的旧实现参数(eventNames/eventNameList)和 fallback 端点 (/event_callback/update)在开放平台并不存在,请求全部失败且被吞成 warning, 新建机器人落地即缺 im.message.receive_v1 / card.action.trigger,收不到消息 和卡片点击。 修复(契约均从 console 前端 bundle 逆向 + live 实测确认): - 事件订阅走增量契约:读 /developers/v1/event/:id 现状 → operation:add 只补 缺失(按 app/user 身份分桶)→ 回读确认;整批被拒时逐个补 - card.action.trigger 是回调不是事件:走 /developers/v1/callback/*,独立切 长连接 + 增量订阅 + 回读 - fail-closed:核心项(im.message.receive_v1 / card.action.trigger)回读仍 缺失时自动配置判失败并停止发版 - VC 会议事件同批带上,给会议监听 bot 顺带止血
P1-1: automateOpenPlatformSetup 结果新增 missingVcEvents,dashboard VC listener 保存两条分支改用 vcListenerEventGateError 门(纯函数,可测)——此前只判 eventWarning && subscribedEventCount===0,baseline 订上而 VC 全失败时(count=8) listener 仍被保存成会议邀请黑洞。 P1-2: 长连接模式以回读为准纳入 critical:callback/switch 失败或 switch 后回读 mode 仍非 4 时(即使 card.action.trigger 已在列表里)fail-closed,不再只记 warning 后照常发版;eventMode 同样回读确认。 新增 4 用例:switch 失败/switch 空转回读兜底/VC-only 失败不阻断普通建 bot 但 门函数拦截/门函数矩阵。
三审 P1:event/switch 返回成功但回读 eventMode 仍为 webhook 时,automation 虽 fail-closed,但 dashboard 非登录失败分支的 listener 门只看 count/missingVcEvents 会放行,保存出订阅名齐却收不到会议邀请的 listener。 修:结果两分支新增 eventModeReady(回读 eventMode===4;早期失败 undefined 保持 best-effort),vcListenerEventGateError 在 eventModeReady===false 时阻断。 新增回归:全订阅+mode=1 → ok:false + 门函数拦截;门函数矩阵补 mode 用例。
Closed
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.
背景(用户反馈的紧急问题)
用户反馈新创建的机器人缺
im.message.receive_v1/card.action.trigger,收不到消息、卡片按钮无响应。根因是两层叠加:
/developers/v1/event/update发eventNames/eventNameList、fallback 到不存在的/event_callback/update,三连全失败且被吞成 warning。当时没暴露——建 bot 走 SDK PersonalAgent 扫码注册,事件平台默认配好。app/create(普通企业自建应用,默认零事件订阅),订阅全指望上面那个坏掉的调用 → 新建 bot 落地即缺核心事件/回调。另一个独立事实:
card.action.trigger在开放平台是「回调」不是「事件」,有独立配置接口(/developers/v1/callback/*)和独立的长连接开关,塞进事件列表本身就订不上。变更(src/setup/open-platform-automation.ts)
/developers/v1/event/:id现状 →operation:'add'只补缺失(按 app/user 身份分桶,eventMode回填读接口返回值)→ 回读确认;整批被拒时逐个补,不让长尾事件(如 drive 评论事件依赖的 scope 不可授予)拖垮核心事件/developers/v1/callback/:id→ 非长连接先callback/switch切 mode 4 →callback/update增量订阅card.action.trigger→ 回读im.message.receive_v1事件 +card.action.trigger回调)回读仍缺失时,自动配置直接返回失败并停止发版,不再静默产出「建好了却不回话」的坏 bot;其余基础事件缺失记 warningBOT_BASELINE_EVENTS拆为BOT_BASELINE_APP_EVENTS(7 事件,a213472c 按申晗核对补上 im.chat.member.bot.deleted_v1 对齐存量 bot)+BOT_BASELINE_CALLBACKS(卡片回调)+BOT_CRITICAL_APP_EVENTS(fail-closed 集),原常量无仓库外消费者。影响面
automateOpenPlatformSetup(botmux setup CLI / dashboard 添加机器人 / VC listener 保存共用)的事件订阅段;scope 导入、redirect、发版逻辑不动subscribedEventCount/eventWarning形状不变(dashboard VC 流程与 event-dispatcher 日志按原语义消费)验证
pnpm exec tsc --noEmit+pnpm build:零错误bmx-e2e-tmp→ 跑修复后automateOpenPlatformSetup(298 scopes、11 订阅、发版成功)→ 独立回读确认 6 基础事件 + 4 VC 事件全订阅、card.action.trigger回调订阅、事件/回调均 mode 4 长连接 →/developers/v1/app/delete删除测试应用无残留