Skip to content

[Bug] Headless CLI auth blocked: api.z.ai/api/auth/z/login returns identical error for valid, invalid, and empty tokens (desktop 3.15.3, Linux) #1126

Open

Description

@BrasidasVI

提交前确认 · Pre-submission checklist

问题类别 · 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

  1. zcode login (headless: node /opt/ZCode/resources/glm/zcode.cjs login zai) — succeeds, "Login successful", credentials written to ~/.zcode/v2/credentials.json
  2. node /opt/ZCode/resources/glm/zcode.cjs --prompt "hi" --json --mode plan --no-color
  3. → [project-access-token] { family: 'zai', stage: 'resolve', code: 'project_token_login_failed' } + Error: Turn execution failed
  4. 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.cjs build 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

Relation to #1001 / #877

Activity

  1. github-actions commented on Oct 20, 2026

    @github-actions

    👋 感谢你的反馈,我们已经收到。

    • 维护者看到后会尽快回复你。
    • 状态保持为 status: 待评估,你可以随时补充信息。
    • 信息不全时我们会打上 needs: 更多信息 标签并 @ 你。

    👋 Thanks — we've received your issue.

    • A maintainer will get back to you as soon as we can.
    • Status stays at status: 待评估 (Triage); feel free to add context.
    • If we need more details, we'll add needs: 更多信息 and ping you.
  2. BrasidasVI commented on Oct 20, 2026

    @BrasidasVI
    Author

    The ask · 希望维护者确认的两个问题

    Two questions from the original report (adding here since the issue body states the evidence but not the ask):

    1. Is POST https://api.z.ai/api/auth/z/login intentionally 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.
    2. If the endpoint has moved or been replaced, what is the supported headless auth path for --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.

  3. dominiclafleur commented on Oct 30, 2026

    @dominiclafleur

    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 zai completes ("Login successful", fresh zcodejwttoken with iat = login moment, account-provider keys written), then each -p run 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, the zcodejwttoken, and arbitrary garbage alike.

    Additional upstream half (before any CLI login): with only the desktop app logged in, standalone zcode -p fails earlier with "Select a model before sending a message". Pinned down against the v3.16.2 source: the standalone registry materializes account providers only from account-provider:* keys in ~/.zcode/v2/credentials.json (process-provider-registry-runtime.ts standalone branch), and the desktop login flow writes only oauth:* keys, so the registry view is empty and no model can be selected. zcode login zai is what writes the account-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 tui fails with "Cannot find package '@zcode/tui'" (not present in the app bundle), so within the shipped bundle /login zai-coding-plan-api-key has no entry point outside the app; (2) the zcode login subcommand only accepts zai|bigmodel (no api-key form). Headless credential configuration has no shipped entry point other than zcode 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.

  4. belarbi2733 commented on Nov 26, 2026

    @belarbi2733

    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:

    • 8af07516-4d76-4191-b93d-d0812772f0ca
    • 9187d036-8f5b-491b-be97-75e540dd46d2
    • b1a0d2d9-2431-4ad9-8834-0ff0da8d7a68

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions