Repository navigation
fix(trae): redeem auth code on callback and handle CN host fallback - #309
Merged
Merged
Conversation
caigee-cmd
requested changes
Oct 19, 2026
caigee-cmd
left a comment
Owner
There was a problem hiding this comment.
感谢提交!浏览器登录在回调时直接完成换码这部分修复很有价值,解决了短信登录耗时长导致 code 过期、最终显示 account not found 的问题,单次 code 防重复兑换的处理也很周到。
合并前需要调整以下几点:
- 设备 ID 规范化与 main 的现有结论冲突。main 上
headers.go的注释写的是:纯数字 id 必须原样发送,加aha-前缀反而会被 9074 拒绝。本 PR 改为把非 32 位 hex 的 id 一律 MD5 映射为aha-<md5>,另外已经带aha-但后缀不是 32 位 hex 的 id 也会被改写。请任选其一:- 用真实账号(最好国内、国际各一个,覆盖纯数字 device id 的新登录)验证签到能成功,并在 PR 中附上脱敏后的结果;
- 或者把设备 ID 改动拆到单独的 PR,本 PR 只保留登录修复。
- 请删除或收敛新增的调试日志。目前
StartLogin会打出完整的 callback URL 和 trace(即 OAuth state),ExchangeAuthCode失败时会打出完整的上游 payload,存在泄露登录态的风险。建议只保留失败日志,并且只记录 account、host、status 和错误码,不要输出 URL、state、payload。 ExchangeAuthCode里的lastErr从未赋值,循环后的return credential, lastErr是无效代码,请清理。- 目前分支落后 main,请 rebase 到最新 main 后再跑一遍
go test ./...。
改完后 @ 我一下,我会尽快再看。谢谢!
One bilingual fragment per PR, per changelog/unreleased/README.md.
Per review on caigee-cmd#309: - Remove the new debug logs that could leak login state: StartLogin no longer logs the callback URL and OAuth trace; acceptCallback no longer logs the parse error (url.Parse echoes the raw URL carrying the one-shot code); redeemAsync success/start logs removed, and its failure log now records only account + classified status/code since the full error message can embed the upstream payload; ExchangeAuthCode logs status + extracted error code instead of the raw payload. - Remove the dead 'var lastErr' / post-loop 'return credential, lastErr' in ExchangeAuthCode — lastErr was never assigned and err is always nil there. - The device-id normalization commit is split out of this PR; the changelog fragment now covers only the login fix.
favoroo
force-pushed
the
feat/trae-callback-checkin
branch
from
October 19, 2026 04:56
ccec128 to
9d13846
Compare
Contributor
Author
|
@caigee-cmd 已按 review 调整:
@caigee-cmd 麻烦再看一下,谢谢! |
caigee-cmd
approved these changes
Oct 19, 2026
caigee-cmd
left a comment
Owner
There was a problem hiding this comment.
LGTM. Review follow-ups look good: device-id change split out, sensitive logs trimmed, dead lastErr removed, rebased. Merging.
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
Fix Trae browser login so it completes on the callback itself.
account not found. The callback now exchanges the code and stores the credential immediately. Pasted callback URLs still work and now actually redeem; a URL carrying onlyloginTraceIDis accepted; the single-use code is exchanged exactly once even when callback, poll, and paste overlap.Review follow-ups (2026-10-19)
aha-<md5>remapping conflicted with main's verified conclusion (numeric ids must be sent as-is; anaha-prefix is rejected with 9074), so that commit is removed from this PR and will come back as a separate PR with real-account verification (CN + Global, fresh logins with numeric device ids) before it is considered.acceptCallbackparse failure no longer echoes the parse error either (it embeds the raw URL with the one-shot code).lastErrinExchangeAuthCodeand the unreachable post-loop return are gone.main;go test ./...green.Tests
go build ./...,go vet ./...,go test ./...,git diff --check