Repository navigation
Description
提交前确认 · Pre-submission checklist
- Searched existing issues — related, not duplicates: [Bug] CLI 3.15.1 built from source: every model request fails with 401 — api.z.ai/api/auth/z/login returns "Z.ai user information is invalid" right after successful zcode login #1001 (same error, Oct 18), [Bug] ZCode 3.14.4 (Linux): OAuth token exchange returns HTTP 500 after a successful browser authorization (login fails, agent blocked) #877 (same exchange failing, Sep 30). This report adds decisive new evidence; see "Relation to [Bug] CLI 3.15.1 built from source: every model request fails with 401 — api.z.ai/api/auth/z/login returns "Z.ai user information is invalid" right after successful zcode login #1001 / [Bug] ZCode 3.14.4 (Linux): OAuth token exchange returns HTTP 500 after a successful browser authorization (login fails, agent blocked) #877" below.
问题类别 · Category: 账号 / 登录 · Account / Login
涉及的 Agent 框架 · Framework: ZCode Agent(自研)
严重程度 · Severity: 阻塞使用 · Blocking — all headless --prompt usage fails, 100% of the time since 2026-10-19
复现频率 · Reproducibility: 必现 · Always
问题描述 · Description
Every headless CLI run fails at authentication with project_token_login_failed. Cause isolated to POST https://api.z.ai/api/auth/z/login (the project-token exchange the CLI performs before each turn):
$ curl -s -X POST https://api.z.ai/api/auth/z/login -H 'Content-Type: application/json' -d '{"token":"anything"}'
{"code": 500, "msg": "Z.ai user information is invalid"}
The endpoint returns the byte-identical response for an empty string, a garbage string, and a valid, seconds-old OAuth token — it is not validating tokens at all. So this is an endpoint-level condition, not an account problem: the desktop app works fine on the same account at the same time.
复现步骤 · Steps to reproduce
zcode login(headless:node /opt/ZCode/resources/glm/zcode.cjs login zai) — succeeds, "Login successful", credentials written to~/.zcode/v2/credentials.jsonnode /opt/ZCode/resources/glm/zcode.cjs --prompt "hi" --json --mode plan --no-color- →
[project-access-token] { family: 'zai', stage: 'resolve', code: 'project_token_login_failed' }+Error: Turn execution failed - Or the exchange directly:
curl -s -X POST https://api.z.ai/api/auth/z/login -H 'Content-Type: application/json' -d '{"token":"anything"}'
期望表现 · Expected behavior
The exchange returns {"code":0, ...} with a project access token, as this account's CLI usage required before 2026-10-19.
实际表现 · Actual behavior
{"code":500,"msg":"Z.ai user information is invalid"} — identical for every token value. Also reproduces in a stripped environment (env -i, no ZCODE_* vars) and with --surface desktop; ZCODE_DEBUG=1 adds no detail. A fresh zcode login immediately beforehand does not help.
环境 · Environment
- ZCode desktop 3.15.3 (Linux x64, auto-updated 2026-10-19); bundled CLI reports 0.16.9 (
zcode.cjsbuild dated 2026-10-13); node v22.23.3 - GLM individual coding plan (
account:zai-individual-coding-plan, GLM-5.3) - Provider-catalog resolution is fine (pinned via
ZCODE_BUILTIN_PROVIDER_CONFIG_FILE/ the app-injected runtime copy); the failure is at the token exchange
Trace IDs
66d8bc1b-bdbb-48cb-90f1-781b67137ab1 · 8501b8a5-b3c4-490f-8ccf-041b652bf9b7 · 94bd8201-aa6e-48b0-adaa-76dfb31060d4
- [Bug] ZCode 3.14.4 (Linux): OAuth token exchange returns HTTP 500 after a successful browser authorization (login fails, agent blocked) #877 (3.14.4, Sep 30): same exchange returning HTTP 500 right after successful browser authorization
- [Bug] CLI 3.15.1 built from source: every model request fails with 401 — api.z.ai/api/auth/z/login returns "Z.ai user information is invalid" right after successful zcode login #1001 (3.15.1, Oct 18): same error right after successful
zcode login— still open - New evidence here: the exchange ignores token content entirely (empty / garbage / valid all byte-identical), proving an endpoint-level condition rather than credential- or account-specific state. Timeline note: this account's CLI usage only started failing after the 2026-10-19 CLI rebuild, which made this exchange a hard dependency of every headless turn.
Activity
github-actions commentedon Oct 20, 2026
👋 感谢你的反馈,我们已经收到。
status: 待评估,你可以随时补充信息。needs: 更多信息标签并 @ 你。👋 Thanks — we've received your issue.
status: 待评估(Triage); feel free to add context.needs: 更多信息and ping you.BrasidasVI commentedon Oct 20, 2026
The ask · 希望维护者确认的两个问题
Two questions from the original report (adding here since the issue body states the evidence but not the ask):
POST https://api.z.ai/api/auth/z/loginintentionally disabled (e.g. an auth migration in progress since 2026-10-19), or is this a regression? The byte-identical{"code":500,"msg":"Z.ai user information is invalid"}for empty / garbage / valid seconds-old OAuth tokens suggests the request isn't reaching token validation at all.--prompt/ CI usage now (zcode login zai+ token exchange), and is there an interim workaround we can apply on our side?Happy to test any interim path or capture additional traces — headless usage has been 100% blocked on this account since 2026-10-19, while the desktop app on the same account keeps working.
dominiclafleur commentedon Oct 30, 2026
Confirming on a current build, plus one additional earlier-stage half of this failure (its symptom is tracked in #1044; the provider-registry mechanism below is what I can add).
Confirmation (3.16.3 desktop, bundled CLI 0.17.0, macOS arm64, 2026-10-30):
zcode login zaicompletes ("Login successful", freshzcodejwttokenwith iat = login moment, account-provider keys written), then each-prun I tried fails (2/2) with the identical[project-access-token] code: project_token_login_failed. Re-running your control here (responses diffed identical): the endpoint returns{"code":500,"msg":"Z.ai user information is invalid"}for the freshly-issued OAuth token, thezcodejwttoken, and arbitrary garbage alike.Additional upstream half (before any CLI login): with only the desktop app logged in, standalone
zcode -pfails earlier with "Select a model before sending a message". Pinned down against the v3.16.2 source: the standalone registry materializes account providers only fromaccount-provider:*keys in~/.zcode/v2/credentials.json(process-provider-registry-runtime.ts standalone branch), and the desktop login flow writes onlyoauth:*keys, so the registry view is empty and no model can be selected.zcode login zaiis what writes theaccount-provider:*keys, which is what leads from the desktop-only state into this issue's failure. Relevant to #1044's "no model selection in headless": the missing selection is a symptom of the empty provider view, not just a missing flag.Two related product facts (3.16.3 bundle): (1)
node <app>/Resources/glm/zcode.cjs tuifails with "Cannot find package '@zcode/tui'" (not present in the app bundle), so within the shipped bundle/login zai-coding-plan-api-keyhas no entry point outside the app; (2) thezcode loginsubcommand only acceptszai|bigmodel(no api-key form). Headless credential configuration has no shipped entry point other thanzcode login zai, which lands on this issue's failure.Happy to be corrected on any of the source readings: all claims above are from the v3.16.2 OSS repo with string-level cross-checks against the 3.16.3 bundle.
belarbi2733 commentedon Nov 26, 2026
Confirming on macOS too (ZCode desktop 4.0.0, bundled CLI 0.18.0, macOS 27.0 build 26A428, Node v24.13.0, GLM Coding Max plan).
After a successful
zcode login zai(23 Nov 2026), every headless run fails:zcode --cwd "" -p "" --no-color --mode plan < /dev/null
[project-access-token] { family: 'zai', stage: 'resolve', code: 'project_token_login_failed' }
Error: Turn execution failed
3/3 attempts on 24 Nov 2026, traceIds:
The desktop app works fine on the same account at the same time.
Note: the runs were launched from a non-interactive bash script, so ZCODE_BUILTIN_PROVIDER_CONFIG_FILE / ZCODE_PERSONAL_PROVIDER_CONFIG_FILE (exported in ~/.zshrc) may not have been set.