Repository navigation
fix(auth): bytedcli 已登录时 /login bytedcli 报已授权,发起失败显示脱敏原因 - #3540
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 17, 2026 09:30
Owner
Author
自动评审结论:可合(head
|
Owner
Author
|
已 squash 合入 master(7a7307e2)。 合后 follow-up(非阻断,供后续优化): 以上为自动评审的初步意见,最终以维护者审阅为准。 |
|
@deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 7a7307e…697de2f8e(10 个提交),同批合入的还有 #3552 #3556 #3530 #3558 #3563 #3561 #3562 #3560 #3564,失败不一定由本 PR 引起。
|
This was referenced Nov 18, 2026
|
🚀 Released in v3.59.20 |
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.
问题
bytedcli 升级后,已经登录 ByteCloud 的人执行
/login bytedcli,会收到「❌ 无法发起 ByteCloud 授权:bytedcli auth login --begin」。实际上他已经授权了。根因(已对照 bytedcli 源码,并在隔离 HOME 里实测确认)
auth login --begin --json在发起前会先检查有没有现成的登录。如果已经登录,就直接返回这个登录,不再给链接:{"status":"success","data":{…,"message":"Already authenticated","login_status":"success","already_authenticated":true}}0.185.0 → 0.186.0 的
handleBeginAuthLogin只多了这一处判断。机群上的 bytedcli 会自动升级,所以这个变化是静默到达的。--begin会先把它收尾,返回login_status:"success"(already_completed: true|false),同样不带链接。status=success+verification_uri_complete+complete_token」这一种形状,不符合的一律当作发起失败,而且只报一句固定文案。--begin的 stdout 是带链接的 envelope,stderr 另有一行{"event":"qr_image_ready",…};重复调用会复用同一条授权(challenge_reused: true)。{"status":"error","data":null,"error":{code,message,hint}},exit 1,stderr 另有一行{"event":"action_required","data":{…}}。auth status --json仍是{status, data:{authenticated:boolean,…}},格式没变。--beginexit 0 且什么都不输出。改动
src/services/bytedcli-auth.tsstartBytedcliLogin,发起授权现在有三种结果:challenge:拿到链接,行为同原来;authorized:bytedcli 报告已登录(already_authenticated/already_completed/ 无链接的login_status: success)。CLI 的说法本身不算数:要再走一遍每轮铸 JWT 前用的同一个个人状态检查(auth status,含撤销 epoch 判断和 app 身份拒绝),确认后才判为已授权,并清掉 botmux 侧残留的待确认授权;failed:附带 bytedcli 原始错误的摘要。优先取 envelope 里的error.code: message,其次取action_required事件,再次取纯文本输出的前两行(去掉堆栈)。token=等凭据形态,以及设备码(user_code=…、code: …、XXXX-XXXX);…Error:行,跳过 Node 警告和崩溃时打印的源码/插入符行。parseEnvelope不再把带顶层status的{event,…}事件行当成结果。beginBytedcliLogin(只要链接的调用方用)保持原签名,内部改调startBytedcliLogin。/login bytedcli(command-handler.ts):/logout(注明会一并撤销本机其它授权),后面跟本 Bot 是否启用身份注入的说明(和授权成功时同一套)。provider-auth-request.ts/dashboard-ipc-server.ts):如果发起时发现已经授权,按ready处理,并把这个登录交给当前轮次(与「预检查已授权」同一条路径);失败时 agent 看到的unavailable消息里带上脱敏原因。agent 拿到的消息依旧不含链接。影响面
turn-cli-identity)和无人值守提醒(capability-authorization)仍用beginBytedcliLogin,行为不变。credentialSource非 local 且已绑定平台)不走这条路径,不受影响。--begin仍会返回链接,走原来的路径。顺带修的测试卫生问题
ipc-auth-request里的 Meego 用例会顺带列出缺失的 ByteCloud 授权,经capability-authorization调到真实的bytedcli auth login --begin。CI 上没装 bytedcli 所以没暴露,但在装了 bytedcli 的开发机上,单元测试会真的向 ByteCloud 发起设备码授权(发生在测试的临时 HOME 里,不影响真实登录态)。现在该 describe 默认给beginBytedcliLogin/startBytedcliLogin加了兜底 spy,行为对齐 CI(不出链接),需要链接或登录状态的用例自己指定。turn-speakers的 spy 也随 dashboard 入口改为startBytedcliLogin。改完后,跑全部相关测试时 bytedcli 不再在临时目录生成授权二维码(以此判断没有真实调用)。测试
新增 / 调整的用例:
test/bytedcli-auth.test.tsstatus时不会盖住结果;test/bytedcli-auth-process.test.ts:真实 spawn + 假 bytedcli 脚本,原样输出 0.195 实测得到的格式(已登录 / 新授权 / 出错三种)。test/ipc-auth-request.test.ts:wrapper 经 IPC 请求授权,背后是假 bytedcli:先报未登录,--begin时把自己那条待确认授权收尾 → 现在回ready。test/command-handler.test.ts:已授权(预检查发现已有登录、已确认的待确认授权)不发起登录;仍待确认的链接照常重发;发起时发现已授权;失败原因。test/provider-auth-request.test.ts:发起时发现已授权 →ready并交给当前轮次;失败时 agent 消息带原因。新测试在旧代码上为红:保留新测试,把
src/换回分支基点后跑上述 5 个文件,52 个用例失败。其中端到端用例是因为真实行为失败,正是现场的误报:变异复验(每次只摘掉一个守卫,对应用例都会变红):
/login bytedcli已授权仍报失败login_status,不认两个旗标XXXX-XXXX设备码规则/login bytedcli去掉预检查已跑的命令与结果:
bytedcli-auth/bytedcli-auth-process/command-handler三个文件按bun-leg-selectors只在 vitest 下跑。独立对抗复核
攻击面:
/logout或另一条/login/done夹在--begin与确认状态之间;/login bytedcli、wrapper 授权请求并发,以及合并调用跨越 epoch 变化。探针用真实模块加假 spawn 和可控闸门。结论:无 P1(没有错误授权、凭据泄露或永久卡死)。
/logout或另一 daemon 撤销落地/login bytedcli发旧链接(原有行为)/login bytedcli加预检查/logout提示(注明影响范围);app 身份单独说明未改的两点:
bytedcli_failed等一致;复核同时确认:在 PATH 最前放一个记日志的陷阱 bytedcli,跑改动的测试文件,真实 bytedcli 零调用。
🤖 Generated with Claude Code