[bug]: auth login — workspace sk-ws- key + *.maas.aliyuncs.com always fails validation (probes /api/v1/models → 404, misreported as an invalid key)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 1-2 天
- 新手友好度
- 62/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
- 领域
- authentication, cli
调研方向
The reporter pinpoints the functions by minified names: getApiKeyLoginKind() in bailian-cli-core classifies keys by prefix, and Ko() in bailian-cli-commands picks the models probe path, with Xo() handling explicit --base-url and Uo/Zo() swallowing the 404. Map those minified names to the TypeScript sources and read how key kind and base-URL host decide the probe path. Fix: probe /compatible-mode/v1/models for *.maas.aliyuncs.com hosts (or add a sk-ws- kind) and stop treating a 404 as an auth failure; done when the official console bootstrap step [3/3] succeeds and validation no longer misreports 404 as an invalid key.
由索引模型根据 Issue 内容生成。
描述
CLI version
2.5.1
Skill version (optional)
2.5.1
Node version
v24.10.0
OS
darwin 27.0.0 (macOS 27.0.1, arm64)
Region
intl
Command to reproduce
# Official one-line bootstrap copied verbatim from the Bailian console for a
# Singapore (ap-southeast-1) Model Studio workspace. Key + workspace id redacted.
curl -fsSL 'https://bailian.aliyun.com/api-key.sh' | bash -s -- \
'o1_[REDACTED]' -r ap-southeast-1 -w ws-[REDACTED]
# Steps [1/3] install CLI and [2/3] install skills succeed; [3/3] always fails.
# The bootstrap locally decodes the o1_ blob into an sk-ws-... key, then runs:
bl auth login --config default \
--api-key 'sk-ws-[REDACTED]' \
--base-url 'https://ws-[REDACTED].ap-southeast-1.maas.aliyuncs.com' \
--verbose
# The wrong probe path is visible even without a valid key:
bl auth login \
--api-key 'sk-dummy0000000000000000000000000000000000000000000000' \
--base-url 'https://ws-[REDACTED].ap-southeast-1.maas.aliyuncs.com' \
--verbose
Expected behavior
bl auth login should accept this key. The very same key against the very same base URL succeeds when the OpenAI-compatible path is used:
GET https://ws-[REDACTED].ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/models
→ HTTP 200
{"object":"list","data":[{"id":"qwen3.8-omni-flash",...},{"id":"glm-5.3",...}, ...]}
Workspace gateways at https://{workspace}.{region}.maas.aliyuncs.com only serve /compatible-mode/v1/*, so login validation should probe /compatible-mode/v1/models for them.
Actual behavior
Validation probes the DashScope-native path instead, gets a 404, and reports it as an authentication failure (exit code 3). No config is written, so a subsequent bl auth status says "Not authenticated" even though the key is fine.
GET https://ws-[REDACTED].ap-southeast-1.maas.aliyuncs.com/api/v1/models?page_no=1&page_size=1
→ HTTP 404 Not Found (empty body)
Root cause (bl 2.5.1, minified names)
1. getApiKeyLoginKind() (bailian-cli-core) classifies purely by prefix:
function Ft(e){
let t = e.trim();
return t.startsWith('sk-sp-') ? 'token-plan'
: t.startsWith('sk-') ? 'ordinary'
: 'unknown';
}
A workspace key sk-ws-... therefore lands in ordinary.
2. Ko(base, kind) (bailian-cli-commands) picks the models path from the kind:
function Ko(e, t){
let n = new URL(t === 'token-plan' ? '/compatible-mode/v1/models' : '/api/v1/models', `${e}/`);
if (t === 'ordinary') { n.searchParams.set('page_no','1'); n.searchParams.set('page_size','1'); }
return n.toString();
}
3. Because --base-url was passed explicitly, Xo() short-circuits (if (t.explicitBaseUrl) { ...; return i; }) and never falls back to the Go.ordinary public DashScope endpoints — so exactly one candidate is probed, and it is the wrong path.
4. 404 is a member of the "endpoint responded" set Uo = new Set([200, 400, 401, 403, 404, 405]), so the routing failure is swallowed by Zo() and re-thrown as the generic AUTH error "the key was not accepted by any supported model endpoint."
Note also that Xo() auto-builds https://{workspaceId}.{region}.maas.aliyuncs.com for all six regions in Wo whenever workspace_id is configured — always with kind ordinary, i.e. always against /api/v1/models. So that discovery path is guaranteed to 404 as well. The CLI clearly intends to support these hosts but pairs them with an API path they do not serve.
Consequence: any workspace-scoped sk-ws- key combined with a *.maas.aliyuncs.com base URL can never pass bl auth login, in any region, regardless of network conditions. The official console bootstrap command therefore always fails at step [3/3].
Full output
> GET https://ws-[REDACTED].ap-southeast-1.maas.aliyuncs.com/api/v1/models?page_no=1&page_size=1
> Auth: sk-w...3-hc
> x-dashscope-source-config: {"channel":"bailian-cli","tags":{"t1":"public","t2":"bl","t3":"2.5.1"}}
< 404 Not Found
request_id: a62006a2-3979-938e-8121-ee8de07d69c9
Error: API key validation failed: the key was not accepted by any supported model endpoint.
Hint: Check that the API key belongs to this Base URL.
bl auth login --api-key <your-key>
bl auth status
Get API Key: https://bailian.console.aliyun.com/cn-beijing/?tab=app#/api-key
Exit code: 3
--- as surfaced by the api-key.sh bootstrap wrapper ---
[3/3] Configuring credentials
Error: Bailian CLI authentication failed:
Error: API key validation failed: the key was not accepted by any supported model endpoint.
Hint: Check that the API key belongs to this Base URL.
Exit code: 3
JSON error (optional)
{
"error": {
"code": 3,
"message": "API key validation failed: the key was not accepted by any supported model endpoint.",
"hint": "Check that the API key belongs to this Base URL."
}
}
Already tried
- bl update and skill version aligned with CLI
- bl auth status OK for this command
- Different network / region — still reproduces
How often does this happen?
Always
How was bl invoked?
Terminal (manual)
Notes (optional)
Evidence that this is not a credential, region or network problem
All probes from the same machine, same session. [REDACTED] = the real sk-ws-... key; workspace id redacted.
| # | Probe | Result |
|---|---|---|
| 1 | DNS / TCP / TLS to ws-[REDACTED].ap-southeast-1.maas.aliyuncs.com |
resolves, connect 0.26 s, TLS 0.46 s → network fine |
| 2 | GET {base}/compatible-mode/v1/models with the real key |
200, real model list → the key is valid for this workspace |
| 3 | GET {base}/api/v1/models?page_no=1&page_size=1 with the real key |
404, empty body, request_id a62006a2-3979-938e-8121-ee8de07d69c9 |
| 4 | GET {base}/api/v1/models?page_no=1&page_size=1 with a deliberately invalid key |
401 Unauthorized, request_id a2772a00-991d-95e6-9566-fe85503f391c |
| 5 | GET https://dashscope-intl.aliyuncs.com/api/v1/models?page_no=1&page_size=1 with the real key |
200 (total: 170) |
| 6 | GET https://dashscope.aliyuncs.com/api/v1/models?page_no=1&page_size=1 with the real key |
401 InvalidApiKey — expected, this is an international/Singapore workspace |
| 7 | GET https://token-plan.{cn-beijing,ap-southeast-1}.maas.aliyuncs.com/compatible-mode/v1/models with the real key |
401 InvalidApiKey → not a Token Plan key |
Rows 3 and 4 are the decisive pair: the gateway authenticates first and routes second. An invalid key yields 401; a valid key yields 404 on that path — i.e. /api/v1/models is simply not served on a workspace MaaS gateway. Row 2 confirms the key and workspace are correct. Row 5 explains why the ordinary classification is not unreasonable in general: the public intl endpoint does serve the native path. The bug only bites on *.maas.aliyuncs.com hosts.
Also worth noting: a genuinely broken network would not produce this message. Qo() rethrows the first candidate error for which Zo() is false (no api.httpStatus), so a DNS/TLS/timeout failure surfaces as a network error. Seeing "not accepted by any supported model endpoint" already implies the endpoint answered — which makes the message actively misleading in the 404 case.
Workaround (bypasses the validation path entirely)
bl config set --key api_key --value 'sk-ws-...'
bl config set --key base_url --value https://ws-[REDACTED].ap-southeast-1.maas.aliyuncs.com
bl config set --key workspace_id --value ws-[REDACTED]
bl auth status # → API key (model): config sk-w...
bl text chat --message hi # → normal completion through the workspace gateway
bl config set performs no validation, and real model calls go through /compatible-mode/v1/..., so only the login self-check is affected. Confirmed working on 2.5.1.
No spelling of --base-url can work around this, because Ko() uses new URL('/api/v1/models', base + '/') and an absolute path replaces whatever path the user supplied (e.g. a base URL ending in /compatible-mode/v1).
Omitting --base-url entirely does "succeed" — but only because validation then falls through to Go.ordinary and finds https://dashscope-intl.aliyuncs.com (row 5), silently persisting the public endpoint instead of the workspace gateway the console asked for.
Suggested fix
- In
Ko(), choose the models path by host, not only by key kind: any base URL whose hostname ends in.maas.aliyuncs.com(or whose path already contains/compatible-mode) should be probed at/compatible-mode/v1/models. - Alternatively, add a
workspacekind for thesk-ws-prefix ingetApiKeyLoginKind()and map it to the compatible-mode path. - Cheap safety net: when the explicit base URL returns 404 on the probed path, retry the other kind's path before concluding the key is invalid.
- Remove
404fromUo, or at least distinguish it: a 404 on the models endpoint means "this base URL does not serve this API path", not "this key was rejected". Today it produces exit code 3 /AUTH, which also makesapi-key.shprintBailian CLI authentication failedand skip writing~/.bailian/config.json. - Surface
http_statusandrequest_idin the JSON error for validation failures — the current JSON object has neither, so an agent or CI cannot tell a routing bug from a bad key.
Related
- #241 (closed) — same family: a wrong default endpoint producing HTTP 404 for every request (
vision describepinned to the Coding Plan host). - #267 (open) — same Singapore workspace
sk-ws-key +*.maas.aliyuncs.comsetup, different symptom (local media upload pinned to the China endpoint).
Invoked via the terminal, through the official https://bailian.aliyun.com/api-key.sh bootstrap command copied from the Bailian console.
- 主要语言
- TypeScript
- 星标
- 364
- 派生
- 32
- 平均合并
- 1 天 14 小时
- 30 天内合并 PR
- 36
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelstudioai/cli 的其他 Issue
-
难度 3/5 3-5 天 新手友好度 48/100
modelstudioai/cli#287 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
modelstudioai/cli#286 ·
维护者通常 1 天内回复
-
bug
难度 4/5 1-2 天 新手友好度 48/100
modelstudioai/cli#264 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
modelstudioai/cli#202 · 3 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 modelstudioai/cli 的全部 Issue
相似的 Issue
-
area:desktop area:ui bug platform:macos
难度 2/5 1-3 小时 新手友好度 67/100
anthropics/claude-code#106183 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
feature:App-Tour feature:Chat ready Web
难度 2/5 1-3 小时 新手友好度 62/100
digitalfabrik/integreat-app#4523 · 2 个 reaction ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Required Lexical field accepts two empty paragraphs可能已有人在做 @lazerg 今天认领。 未关闭Bug
难度 2/5 1-3 小时 新手友好度 76/100
payloadcms/payload#19222 ·
维护者通常 1 天内回复