Repository navigation
Description
提交前确认 · Pre-submission checklist
- 我已搜索过现有 issue,确认这不是重复 / I searched existing issues and confirmed this isn't a duplicate.
- 我已阅读 CONTRIBUTING.md / I've read CONTRIBUTING.md.
问题类别 · Category
账号 / 登录 · Account / Login
涉及的 Agent 框架 · Agent framework
ZCode Agent(自研)
严重程度 · Severity
阻塞使用 · Blocking (无法使用核心功能 / core function unusable)
复现频率 · Reproducibility
必现 · Always
问题描述 · Description
"Connect to Z.ai" never completes on the desktop app: the browser reports "Authorization successful", but the app shows "登录失败,请重试" / "Login failed, please retry".
The deep link does reach the app, so the callback routing is fine:
[deep-link] OAuth 回调路由成功 {"state":"...","windowId":1,"provider":"zai","completed":true}
The app then exchanges the code and the endpoint answers HTTP 500 every time:
[zaiOAuth] token request {"method":"POST","url":"https://zcode.z.ai/api/v1/oauth/token",
"body":{"provider":"zai","code":"...","codeLength":17,
"redirect_uri":"https://zcode.z.ai/app/oauth/login?redirect=zcode%3A%2F%2Foauth%2Fcallback&app_version=3.14.4",
"state":"..."}}
[zaiOAuth] token response error {"method":"POST","url":"https://zcode.z.ai/api/v1/oauth/token",
"status":500,"responseHeaders":{"x-request-id":"20260930025531952fc805c88dfa9ca0c1"}}
3 out of 3 attempts today returned HTTP 500, with request-ids 2026093002182481f1d08f9be0e3dad4bb, 2026093002200033d365133046746c96ca, 20260930025531952fc805c88dfa9ca0c1.
Downstream symptoms: oauth.pollPendingOAuth FAIL {"message":"zai_oauth_required"} raised from ZaiBusinessTokenResolver.exchangeBusinessToken, and the agent stays blocked with 当前没有可用的模型供应商和模型,请先登录或配置 API Key.
复现步骤 · Steps to reproduce
- Open ZCode on Linux and click "Connect to Z.ai".
- Complete the authorization in the browser ("Authorization successful").
- The app shows "登录失败,请重试"; the agent log shows
zai_oauth_required. - Independently of any account, the failure is reproducible with an invalid code (the request shape is accepted; an incomplete body returns 400):
curl -s -w '\n%{http_code}\n' -X POST https://zcode.z.ai/api/v1/oauth/token \
-H 'Content-Type: application/json' \
-d '{"provider":"zai","code":"code0000000000dummy","redirect_uri":"https://zcode.z.ai/app/oauth/login?redirect=zcode%3A%2F%2Foauth%2Fcallback&app_version=3.14.4","state":"0123456789abcdef0123456789abcdef"}'
# -> 500 {"code":2007,"msg":"http error"}
# same body without redirect_uri -> 400 {"code":3001,"msg":"parameter error"}
# repeated calls return 429, so avoid hammering the endpoint期望表现 · Expected behavior
After a successful browser authorization the token exchange should return a token and the app should be signed in. An invalid or expired code should produce a 4xx with a meaningful message, not a 500.
实际表现 · Actual behavior
HTTP 500 on every exchange, so the login never completes and the agent cannot run.
ZCode 版本 · ZCode version
3.14.4 (.AppImage, linux-x64). The app's own update check reports "latest version: 3.14.4".
设备 / 系统 / 浏览器 · Device / OS / Browser
Ubuntu / GNOME on Wayland / Firefox / AppImage launched with --no-sandbox.
截图 / 录屏 / 日志 · Screenshots / Recordings / Logs
Log lines quoted above, from ~/.zcode/v2/logs/2026-09-30.log.
Activity
github-actions commentedon Sep 30, 2026
👋 感谢你的反馈,我们已经收到。
status: 待评估,你可以随时补充信息。needs: 更多信息标签并 @ 你。👋 Thanks — we've received your issue.
status: 待评估(Triage); feel free to add context.needs: 更多信息and ping you.felipeatp commentedon Sep 30, 2026
Update (2026-09-30 00:51 local) — this 500 is real but it is not always what blocks the login, and in my case it was not the blocker.
The same flow completed successfully while this endpoint was still failing:
After that run the session exists (
credentials.jsonnow containsoauth:zai:access_token,oauth:zai:user_info,oauth:active_provider, plus anaccount-provider:...:zai-individual-coding-plan:...credential), so the app is signed in.What actually blocked login here was a second, independent failure: the business-token exchange goes to
https://api.z.ai/api/auth/z/login(ZaiBusinessTokenResolver.exchangeBusinessToken, wired tobusinessLoginUrl), and on this network every request toapi.z.aiwas timing out —api.z.aipublishes AAAA records that are unroutable here, and Node/undici's happy-eyeballs aborts every connect attempt (250 ms attempt timeout vs ~286 ms RTT). That producedoauth.pollPendingOAuth FAIL {"message":"zai_oauth_required"}and the login never completed. See #876 for the full diagnosis and the reproduction.Once
api.z.aiwas pinned to its IPv4 addresses in/etc/hosts, the business-token exchange succeeded, the polling flow completed and the login went through — with this 500 still being returned on the code exchange.So there are two separate issues in this path:
POST https://zcode.z.ai/api/v1/oauth/tokenreturns HTTP 500 for every code exchange (reproducible with an invalid code too — reported here).api.z.aifails on networks whereapi.z.ai's AAAA records are unroutable, which is what makes the login fail end to end ([Bug] ZCode 3.14.4 (Linux): every agent model request fails with "Cannot connect to API" / ETIMEDOUT — api.z.ai publishes AAAA records this network cannot route (Node happy-eyeballs 250 ms) #876).Point 1 is worth fixing on its own (a 500 for an invalid code should be a 4xx), but it does not appear to block login by itself.