Skip to content

Commit d24b41d

Browse files
committed
feat: Remove the logic related to region
1 parent a5d055f commit d24b41d

22 files changed

Lines changed: 81 additions & 93 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
66

77
[中文版](CHANGELOG.zh.md) · [README](README.md) · [Contributing](CONTRIBUTING.md)
88

9+
## [Unreleased]
10+
11+
### Removed
12+
13+
- Global `--region`, environment variable `DASHSCOPE_REGION`, and `bl config set --key region`. DashScope API endpoint is selected only via `--base-url`, `DASHSCOPE_BASE_URL`, or `base_url` in `config.json` (defaults to the China mainland URL). Existing `region` entries in `config.json` are ignored; set `base_url` explicitly if you relied on `us` / `intl`.
14+
915
## [1.3.2] - 2026-06-12
1016

1117
### Fixed

CHANGELOG.zh.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
[English](CHANGELOG.md) · [README](README.zh.md) · [参与贡献](CONTRIBUTING.zh.md)
88

9+
## [未发布]
10+
11+
### 移除
12+
13+
- 全局 `--region`、环境变量 `DASHSCOPE_REGION` 以及 `bl config set --key region`。DashScope API 地址仅通过 `--base-url``DASHSCOPE_BASE_URL``config.json` 中的 `base_url` 指定(默认中国大陆)。`config.json` 中的 `region` 字段不再读取;若曾依赖 `us` / `intl`,请改为设置对应的 `base_url`
14+
915
## [1.3.2] - 2026-06-12
1016

1117
### 修复

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bl auth status --output json
102102
bl text chat --message "ping" --non-interactive --output json
103103
```
104104

105-
若失败:根据 stderr / JSON 中的 `hint``message` 排查(网络、Key 无效、region 等)。全局 region:`--region cn|us|intl`,默认 `cn`
105+
若失败:根据 stderr / JSON 中的 `hint``message` 排查(网络、Key 无效、`base_url` 等)。DashScope 端点:使用 `--base-url` / `bl config set --key base_url` / `DASHSCOPE_BASE_URL`,默认中国大陆 `https://dashscope.aliyuncs.com`
106106

107107
---
108108

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export BAILIAN_WORKSPACE_ID=ws-...
172172
bl config show
173173

174174
# Set defaults
175-
bl config set --key region --value us
175+
bl config set --key base_url --value https://dashscope-us.aliyuncs.com
176176
bl config set --key default_text_model --value qwen-turbo
177177
bl config set --key timeout --value 600
178178

README.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export BAILIAN_WORKSPACE_ID=ws-...
167167
bl config show
168168

169169
# 设置默认值
170-
bl config set --key region --value us
170+
bl config set --key base_url --value https://dashscope-us.aliyuncs.com
171171
bl config set --key default_text_model --value qwen-turbo
172172
bl config set --key timeout --value 600
173173

packages/cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export BAILIAN_WORKSPACE_ID=ws-...
172172
bl config show
173173

174174
# Set defaults
175-
bl config set --key region --value us
175+
bl config set --key base_url --value https://dashscope-us.aliyuncs.com
176176
bl config set --key default_text_model --value qwen-turbo
177177
bl config set --key timeout --value 600
178178

packages/cli/README.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export BAILIAN_WORKSPACE_ID=ws-...
167167
bl config show
168168

169169
# 设置默认值
170-
bl config set --key region --value us
170+
bl config set --key base_url --value https://dashscope-us.aliyuncs.com
171171
bl config set --key default_text_model --value qwen-turbo
172172
bl config set --key timeout --value 600
173173

packages/cli/src/commands/config/set.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
import { emitResult } from "../../output/output.ts";
1313

1414
const VALID_KEYS = [
15-
"region",
1615
"base_url",
1716
"output",
1817
"output_dir",
@@ -58,7 +57,7 @@ export default defineCommand({
5857
{
5958
flag: "--key <key>",
6059
description:
61-
"Config key (region, base_url, output, output_dir, timeout, api_key, access_token, default_*_model, access_key_id, access_key_secret, workspace_id)",
60+
"Config key (base_url, output, output_dir, timeout, api_key, access_token, default_*_model, access_key_id, access_key_secret, workspace_id)",
6261
},
6362
{ flag: "--value <value>", description: "Value to set" },
6463
],
@@ -90,13 +89,6 @@ export default defineCommand({
9089
}
9190

9291
// Validate specific values
93-
if (resolvedKey === "region" && !["cn", "us", "intl"].includes(value)) {
94-
throw new BailianError(
95-
`Invalid region "${value}". Valid values: cn, us, intl`,
96-
ExitCode.USAGE,
97-
);
98-
}
99-
10092
if (resolvedKey === "output" && !["text", "json"].includes(value)) {
10193
throw new BailianError(
10294
`Invalid output format "${value}". Valid values: text, json`,

packages/cli/src/error-handler.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import { API_KEY_PAGE } from "./urls.ts";
99

1010
const LABEL_WIDTH = 13;
1111

12+
/** Short reminder; full resolution order matches `loadConfig` in bailian-cli-core. */
13+
const BASE_URL_HINT =
14+
"If the DashScope host is wrong, check baseUrl (--base-url, bl config show, or DASHSCOPE_BASE_URL).";
15+
1216
function pad(label: string): string {
1317
return label.padEnd(LABEL_WIDTH);
1418
}
@@ -76,7 +80,7 @@ function pickNetworkHint(code: string | undefined): string {
7680
switch (code) {
7781
case "ENOTFOUND":
7882
case "EAI_AGAIN":
79-
return "DNS resolution failed. Check DASHSCOPE_BASE_URL or your DNS / network.";
83+
return `DNS resolution failed. Check DNS / network. ${BASE_URL_HINT}`;
8084
case "ECONNREFUSED":
8185
return "Connection refused. Check the target host/port and proxy settings.";
8286
case "ECONNRESET":
@@ -86,13 +90,13 @@ function pickNetworkHint(code: string | undefined): string {
8690
"export HTTPS_PROXY=http://127.0.0.1:<proxy-port>"
8791
);
8892
case "ETIMEDOUT":
89-
return "Connection timed out. Check your network or try a different region.";
93+
return `Connection timed out. Check your network. ${BASE_URL_HINT}`;
9094
case "CERT_HAS_EXPIRED":
9195
case "UNABLE_TO_VERIFY_LEAF_SIGNATURE":
9296
case "DEPTH_ZERO_SELF_SIGNED_CERT":
9397
return "TLS certificate error. Check system clock and CA bundle.";
9498
default:
95-
return "Check network connection, proxy settings (HTTP_PROXY / HTTPS_PROXY), and DASHSCOPE_BASE_URL.";
99+
return `Check network and proxy (HTTP_PROXY / HTTPS_PROXY). ${BASE_URL_HINT}`;
96100
}
97101
}
98102

@@ -166,9 +170,8 @@ export function handleError(err: unknown): never {
166170
"Request timed out.",
167171
ExitCode.TIMEOUT,
168172
"Try increasing --timeout (e.g. --timeout 60).\n" +
169-
"If this happens on every request with a valid API key, you may be hitting the wrong region.\n" +
170-
"Run: bl auth status — to check your credentials and region.\n" +
171-
"Run: bl config set --key region --value cn — to override the region.",
173+
`${BASE_URL_HINT}\n` +
174+
"Run: bl auth status — to check credentials.",
172175
{ cause: err },
173176
);
174177
return handleError(timeout);

packages/cli/tests/e2e/auth.e2e.test.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,25 @@ describe("e2e: auth", () => {
160160
expect(data.dashscope_commands?.method).toBeDefined();
161161
});
162162

163-
test.skipIf(!isDashScopeE2EReady())("auth status --output json --quiet --region cn", async () => {
164-
const { stdout, stderr, exitCode } = await runCli([
165-
"auth",
166-
"status",
167-
"--non-interactive",
168-
"--output",
169-
"json",
170-
"--quiet",
171-
"--region",
172-
"cn",
173-
]);
174-
expect(exitCode, stderr).toBe(0);
175-
const data = parseStdoutJson<{ authenticated?: boolean; dashscope_commands?: unknown }>(stdout);
176-
expect(data.authenticated).toBe(true);
177-
expect(data.dashscope_commands).toBeDefined();
178-
});
163+
test.skipIf(!isDashScopeE2EReady())(
164+
"auth status --output json --quiet --base-url 国内",
165+
async () => {
166+
const { stdout, stderr, exitCode } = await runCli([
167+
"auth",
168+
"status",
169+
"--non-interactive",
170+
"--output",
171+
"json",
172+
"--quiet",
173+
"--base-url",
174+
"https://dashscope.aliyuncs.com",
175+
]);
176+
expect(exitCode, stderr).toBe(0);
177+
const data = parseStdoutJson<{ authenticated?: boolean; dashscope_commands?: unknown }>(
178+
stdout,
179+
);
180+
expect(data.authenticated).toBe(true);
181+
expect(data.dashscope_commands).toBeDefined();
182+
},
183+
);
179184
});

0 commit comments

Comments
 (0)